Page 1 of 1

Default value when using metadata xml forms.

PostPosted:Thu May 31, 2018 12:48 am
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

Re: Default value when using metadata xml forms.

PostPosted:Thu May 31, 2018 3:27 pm
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>

Re: Default value when using metadata xml forms.

PostPosted:Thu May 31, 2018 4:11 pm
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

Re: Default value when using metadata xml forms.

PostPosted:Fri Jun 01, 2018 8:09 am
by lnovoa
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

Re: Default value when using metadata xml forms.

PostPosted:Fri Jun 01, 2018 9:37 am
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

Re: Default value when using metadata xml forms.

PostPosted:Fri Jun 01, 2018 11:23 am
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>

Re: Default value when using metadata xml forms.

PostPosted:Sat Jun 02, 2018 1:07 am
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

Re: Default value when using metadata xml forms.

PostPosted:Sat Jun 02, 2018 4:35 pm
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>

Re: Default value when using metadata xml forms.

PostPosted:Wed Oct 23, 2019 6:13 am
by sonnysiah
1.png
1.png (2.85 KiB) Viewed 35703 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>

Re: Default value when using metadata xml forms.

PostPosted:Sat Oct 26, 2019 9:21 am
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.