I have a form with a simple checkbox. I want to start by checking that box for all my records. Not being a Javascript coder, I need some help.
The field name to check is Added_to_VR-Mailing.
Thanks!!
In my case, the checkbox field is called ‘selected’. You just need to assign the field id of field Added_to_VR-Mailing on line 3 of the code below.
// This script selects all records
function selectAll(){
const selected_id = 'fld-xxxx';
var records = form.getRecords();
for (var index = 0, count = records.length; index < count; index++){
var myRec = records[index];
myRec.setFieldValue(selected_id, true);
}
document.saveAllChanges();
}
selectAll();
The code loops over all records and sets the checkbox value to true.