• Default value when using metadata xml forms.

  • Help us to improve OpenKM! Be part of the Open Source Community.
Help us to improve OpenKM! Be part of the Open Source Community.
Forum rules: Please, before asking something see the documentation wiki or use the forum search function.
 #45995  by cherifmad
 
Good morning,
I have a problem.
I would like to know if it is possible to add a default value when we create an Xml metadata form.
for example :
Code: Select all
<property groups>>property groups
  property group label="Consulting" name="okg:consulting">"okg:consulting".
    <input label="Name" type="text" name="okp:consulting.name "value=" default name"/>" name"/>".
    <input label="Date" type="date" name="okp:consulting.date" value ="default text"/>>default text".
    <checkbox label="Important" name="okp:consulting.important"/>>".
    <textarea label="Comment" name="okp:consulting.comment" value=" textarea by default" />>"okp:consulting.comment" value=" textarea by default".
    <input label="Input label" name="okp:consulting.input1" />"Input label" name="okp:consulting.input1" />
    <separator label="Separator label" name="okp:consulting.separator" />"okp:consulting.separator" /> 
    <input label="Input label" name="okp:consulting.input2" />"Input label="Entrée label" name="okp:consulting.input2" />

    
  </group of goods>>group of goods
I'm trying but there's an error on my screen:

Application error
Class: com.openkm.core.ParseException
Message: Attribute "value" must be declared for element type "input".
Date: Thu May 31 00:46:12 UTC 2018

can you help to resolve it.
thanks for all
 #46002  by lnovoa
 
Hi!,
The xml was not well formed, if it is as you show in the post.
Try this example and you will see the default values.

https://docs.openkm.com/kcenter/view/ok ... field.html
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.9//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.9.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <input label="Name" type="text" name="okp:consulting.name" value="default value"/>
      <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
       <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
        </property-group>
</property-groups>
 #46004  by cherifmad
 
lnovoa wrote: Thu May 31, 2018 3:27 pm Hi!,
The xml was not well formed, if it is as you show in the post.
Try this example and you will see the default values.

https://docs.openkm.com/kcenter/view/ok ... field.html
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.9//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.9.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <input label="Name" type="text" name="okp:consulting.name" value="default value"/>
      <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
       <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
        </property-group>
</property-groups>
Thanks Dear Inovoa, I have try it ( your script) But this error appear ...
how can I resolve and fix this problem
Attachments
erreur 2.png
erreur 2.png (243.73 KiB) Viewed 39678 times
erreur 1.png
erreur 1.png (265.62 KiB) Viewed 39678 times
 #46013  by cherifmad
 
lnovoa wrote: Fri Jun 01, 2018 8:09 am Hi,
In this link, you can see how it is built and then you simply have to add
the value properties and the date format mentioned in the previous post

https://docs.openkm.com/kcenter/view/ok ... ition.html
I saw this link again, I set the default value, but the same error persists.
Please, can you write a script that works very well in your openKM and I will test at home to see where I make my mistakes?
thank you for your understanding
 #46016  by lnovoa
 
Hi!,

for example:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.7.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
    <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
   </property-group>
</property-groups>
 #46019  by cherifmad
 
lnovoa wrote: Fri Jun 01, 2018 11:23 am Hi!,

for example:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.7.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
    <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
   </property-group>
</property-groups>
Sorry, I have executed your Script but an over error appear ... See the screenshot
Thanks for your understanding
Attachments
erreur 2.png
erreur 2.png (213.39 KiB) Viewed 39657 times
erreur 1.png
erreur 1.png (235.1 KiB) Viewed 39657 times
 #46020  by jllort
 
Community DTD latest version is 2.3 not 2.7 as you can see here https://docs.openkm.com/kcenter/view/ok ... table.html

Try with:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.3//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.3.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <input label="Input label"  name="okp:consulting.input" value="test" />
  </property-group>
</property-groups>
 #49146  by sonnysiah
 
1.png
1.png (2.85 KiB) Viewed 35611 times
Hi,

I also have the similar question but it apply to Date field, I need have auto set the current date instead of preset value, is it possible?

I have read the article and also changed the header DTD ver from default 2.0 to 2.9 and the test on preset value work. My OpenKM is 6.3.8 CE running on Windows

extract setting from my test openkm metadata
Code: Select all
</select>
    <input label="DATE CREATED" type="date" name="okp:group.date" value="20191023153000" />     	
    <input label="SUBJECT" name="okp:group.subject" width="200px"/>
    <textarea label="DESCRIPTION" name="okp:group.description"/>
    <input label="CREATED BY" name="okp:group.createdby"/>  
    <input label="LAST VIEW BY" name="okp:group.lastviewby"/>  
  </property-group>
 #49158  by jllort
 
Currently is not possible to preset the current date, should be modified the source code for it. In this scenario the property group should be going into something like a filter for updating the default value before you getting from the API, basically, I'm talking about a second step in the process of getting the metadata form values.

If you wish I can try to give you some clues about in what direction the code should be modified.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.