Script Behavior Question

Viewing 2 reply threads
  • Author
    Posts
  • November 19, 2019 at 8:45 PM #38109

    Stephen Abshire
    Participant

    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?

    November 19, 2019 at 11:25 PM #38110

    Sam Moffatt
    Participant

    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.

    November 20, 2019 at 10:12 AM #38129

    Stephen Abshire
    Participant

    Third parameter worked great thanks!

Viewing 2 reply threads

You must be logged in to reply to this topic.