Script - default value

Hi,
how to setup default form field value from the script?
Jan

Hi,

yes, either setValue() or normally just doo.model.fieldName.value = something
It depends on the data type - setValue is mainly for lines or other object types…
doo.model - Tabidoo Help Center.

With Regards,

Filip

Default value means a pre-designed value which can be changed, but value setting by your example cannot be changed by user in the form.
I need to setup field Type to some value depending on condition and user can override
this value in the form.

Hi,

if you write the values in the On model load section (Scripting), you will achieve your desired result.

HI,
I don’t know where I’m wrong but if I use the following script
const defval = 0
doo.model.defaultval.setValue(defval)
the user cannot override the value 0 in the form.

I used your script in On model load
image
When I load the form I see 0
image
And I can change the value of the field
image

and how to do it if I am not able to set const defval = 0 in On model load but in On model change?

That’s the right way to behave. In On model change, setValue and value are used in response to some condition. As in the example.

if ((doo.model.DUZP.value && doo.model.DUZP.currentlyChanged) || (doo.model.splatnostDnu.value && doo.model.splatnostDnu.currentlyChanged)) {
doo.model.splatnost.setValue(doo.functions.date.addDays(doo.model.DUZP.value,doo.model.splatnostDnu.value));
}

if you use the doo.model.fieldName.setValue = 10; you will never be able to override it.

Philip thanks for the answer, but I don’t know how to write this simple example so that the user can rewrite the result xC after entering the values of xA and xB?
doo.model.xC.value = doo.model.xA.value +doo.model.xB.value

Hi,

could you email us at support@tabidoo.cloud? Where can we sort this out? Thank you, Filip