Adding a value to field in linked form

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk Adding a value to field in linked form

Viewing 2 reply threads
  • Author
    Posts
  • February 27, 2024 at 5:46 PM #50566

    Victor Warner
    Participant

    I would like to know, with a script, to add the value to a field in all the records in a linked form.

    Eg first form (Clients) has a linked to Form (Work), and I wish to add a value to a field in the second form for the records related to a record in the first form, with a script. In the example database attached, adding ‘yes’ to the paid field in the Work form for any of the records linked to one of the persons in the first.

    I am (vaguely) aware that I need to use a loop but cannot work out how to structure the script  (or what actions/commands I need to use).

    Any help gratefully received.

    Attachments:
    You must be logged in to view attached files.
    February 27, 2024 at 6:40 PM #50568

    Daniel Leu
    Participant

    Here we go:

    function Mark_Paid() {
    
       const work_id = 'fld-63db4733fa4546fe9df066f3e921c56a';
       const work__paid_id = 'fld-f823bbee88464542afd84e0c5f2c7fb8';
       // get all work records
       let workRecs = record.getFieldValue(work_id);
       // loop over all work records
       for (workRec of workRecs){
          workRec.setFieldValue(work__paid_id, "Yes");
       }
       // Save changes
       document.saveAllChanges();
    }
    Mark_Paid();
    • This reply was modified 9 months, 4 weeks ago by Daniel Leu.
    • This reply was modified 9 months, 4 weeks ago by Daniel Leu.
    • This reply was modified 9 months, 4 weeks ago by Daniel Leu.
    • This reply was modified 9 months, 4 weeks ago by Daniel Leu.
    March 1, 2024 at 6:39 AM #50575

    Victor Warner
    Participant

    Daniel,

    Thank you very much – very helpful.

    Victor

Viewing 2 reply threads

You must be logged in to reply to this topic.