I am writing a script that touches (read/write) several fields on the form. I am guessing at this point but I think that as each of these fields are touched within the script they are invoking the script again on their own which is causing strange results. Can anyone confirm that this is either possible / not possible and if it is possible how can I stop this behavior so that a script is only executed when one of the fields that are being touched invokes the script?
It is possible that your script can be re-entrant if it watches multiple fields and you call setFieldValue
on one of those fields. There is a third parameter to setFieldValue
that controls if scripts are executed, flip it to a falsy value and scripts won’t be executed from that setFieldValue
invocation. I used to write my own guards because Javascript instance is reused so you can share variables between the other scripts triggered by setFieldValue
. Photo fields can also exhibit the same behaviour but I there isn’t a flag to disable them. For those I try to ensure that the field ID is obscured to prevent Tap Forms from triggering my script field for it.
Third parameter worked great thanks!