stepper

Viewing 7 reply threads
  • Author
    Posts
  • June 21, 2023 at 11:41 AM #49627

    Glen Forister
    Participant

    Is 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

    Brendan
    Keymaster

    You 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 Forister
    Participant

    But, 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 Leu
    Participant

    The field script would be triggered by a change in the stepper field.

    June 21, 2023 at 3:10 PM #49631

    Glen Forister
    Participant

    That is cool.

    How about a script to do that?  Would be really appreciated.

    June 21, 2023 at 10:30 PM #49632

    Brendan
    Keymaster

    Something 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 1 year, 6 months ago by Brendan.
    June 22, 2023 at 9:37 AM #49634

    Glen Forister
    Participant

    Well, 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

    Brendan
    Keymaster

    I’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.

Viewing 7 reply threads

You must be logged in to reply to this topic.