Can I have an example of calling a jscript function from a rule
- This topic has 7 replies, 3 voices, and was last updated 1 year, 5 months ago by .
Viewing 5 reply threads
Viewing 5 reply threads
- You must be logged in to reply to this topic.
Home › Forums › Modern DFFS › Can I have an example of calling a jscript function from a rule
When editing a form, I want to set a “single line of text” field with a substring of a second field whan that field is is changed.
I was thinking that a Rule could pick up the event and a Custom JS function called by that rule would do it.
Can you provide an example of such a Custom function called by a rule please?
Thanks
/Marcus
Doh! you have it already in the Examples. Sorry.
Spoke too soon. Don’t quite get the example.
I want to trigger the update of a specific field when another changes and i want to do the same for twenty fields
i.e.
when A is changed, B is updated
or
when C is changed, D is updated
or
When E is changed, F is updated
or
etc.
Thanks
Did you use the dffs_fieldChanged function from the Custom JS example thread?
You should be able to do it something like this:
function dffs_fieldChanged(fin, new_value, previous_value) {
switch (fin) {
case "fieldA":
setFieldValue("fieldB", new_value.substring(0, 10)); // 10 first characters of fieldA is written to fieldB
break;
case "fieldC":
setFieldValue("fieldD", new_value.substring(0, 10)); // 10 first characters of fieldA is written to fieldB
break;
}
}
Alexander
Thanks Alexander, but what calls this function? Is it called automatically whenever any field is changed?
Thanks
Yes