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.
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.
Daniel,
Thank you very much – very helpful.
Victor