- This topic has 7 replies, 3 voices, and was last updated 2 years ago by
Brendan.
-
AuthorPosts
-
June 21, 2023 at 11:41 AM #49627
Glen ForisterParticipantIs it possible for a stepper on one field add a number to that field and another field as well?
What I want is one field to accumulate a number and periodically be set to zero.
In another filed, I want to have the same stepper used above to accumulate, but to never have it set to zero.
So, I would end up with 2 fields, one with an incremental sum and the second with a total of all.
It is obvious I could use 2 steppers, but I know I would forget at times the second stepper and why do the extra work?
June 21, 2023 at 12:19 PM #49628
BrendanKeymasterYou would need to use a Script Field to manage this. The Script Field would monitor the value of your stepper field and add to the value of the second field.
June 21, 2023 at 12:41 PM #49629
Glen ForisterParticipantBut, if I was able to build a script (which I can’t), could it be activated by the stepper or do I have to go into settings and select the script and run that? That would be more work that activating 2 steppers I would think?
June 21, 2023 at 2:44 PM #49630
Daniel LeuParticipantThe field script would be triggered by a change in the stepper field.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksJune 21, 2023 at 3:10 PM #49631
Glen ForisterParticipantThat is cool.
How about a script to do that? Would be really appreciated.
June 21, 2023 at 10:30 PM #49632
BrendanKeymasterSomething like this should work:
function incrementField() { var field1_id = 'fld-.....'; var field2_id = 'fld-.....'; var field1_value = record.getFieldValue(field1_id); var field2_value = record.getFieldValue(field2_id); record.setFieldValue(field2_id, field2_value + 1); form.saveAllChanges(); } incrementField();
You would need to use the appropriate field IDs from your own form.
-
This reply was modified 2 years ago by
Brendan.
June 22, 2023 at 9:37 AM #49634
Glen ForisterParticipantWell, that was interesting. I lost all the data in my “Total” (second field), and anytime I look at the record or recalculate the “Total” increases sometimes by many times.
I should have backed up my data. That was a big failure.
June 22, 2023 at 3:15 PM #49635
BrendanKeymasterI’m sorry for that. Yes, it’s always important to make backups frequently. Sorry this happened to you.
I didn’t have your document and the script was just off the top of my head and wasn’t tested with your data.
-
This reply was modified 2 years ago by
-
AuthorPosts
You must be logged in to reply to this topic.