Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › What causes a script in a form field to execute?
- This topic has 4 replies, 3 voices, and was last updated 2 years ago by richard maliszewski.
-
AuthorPosts
-
December 2, 2022 at 2:52 PM #48402
richard maliszewskiParticipantI am battling onward with my envelope-system. Have prototyped a “transfer” form…entries in a record therein, when my field script runs, create correct entries in both the “to” and “from” envelopes. But thus far, I’ve only been able to run the script from the script editor. It’s my intent to create a layout for this form with a commit button that runs this script. This has to be simple/obvious, but several searches for relevant posts haven’t gotten me anywhere yet.
Any help for the blind here very appreciated.
–Richard
December 2, 2022 at 4:37 PM #48403
Lane RobinsonParticipantI recently learned that for Field Scripts, any time a field changes that is referenced in your script, the script will execute.
With Form scripts that doesn’t happen. You manually run those.
Here is where it states that in the documentation. https://www.tapforms.com/help-mac/5.3/en/topic/scripts
- This reply was modified 2 years ago by Lane Robinson.
December 2, 2022 at 4:45 PM #48405
Lane RobinsonParticipantI’ll further add something that happened to me. This may or may not be something you are facing. I thought a script wasn’t executing properly. I eventually realized that it was getting data from another field that wasn’t updated yet. It was a calculation field that also references another field, and it’s turtles, always the way down. I’m rewriting my script to avoid this.
December 2, 2022 at 6:53 PM #48407
BrendanKeymasterHi Lane,
I’m glad you’re managing to work through these issues. Welcome to the world of programming! Things don’t always go the way you hope or expect. That’s my life programming Tap Forms! :)
A script is triggered, as you’ve found out, when the value in whatever field is reference by
var some_value = record.getFieldValue('fld-.....');
changes.Thanks!
Brendan
- This reply was modified 2 years ago by Brendan.
December 5, 2022 at 10:55 AM #48436
richard maliszewskiParticipantBrendan, does this mean that a change to a record value referenced by its field ID in a variable will also cause that record’s script(s) to execute. For example, I have code that looks like:
var transAmtFldId = transAmtFld.getId();
var transAmt = record.getFieldValue(transAmtFldId);In that form’s record script field.
Will an externally caused change to the field value fetched into “transAmt” will cause the record’s script to run? Are you actually tracking references, or tracking explicit field ID values in code? The examples I see always seem to show the latter, but that may be for simplicity.
–Richard
-
AuthorPosts
You must be logged in to reply to this topic.