Javascript Help

Tagged: 

Viewing 1 reply thread
  • Author
    Posts
  • November 8, 2023 at 10:16 AM #50103

    Peter Chamalian
    Participant

    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!!

    November 8, 2023 at 11:56 AM #50104

    Daniel Leu
    Participant

    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.

    • This reply was modified 5 months, 3 weeks ago by Daniel Leu.
    • This reply was modified 5 months, 3 weeks ago by Daniel Leu.
    • This reply was modified 5 months, 3 weeks ago by Daniel Leu.
Viewing 1 reply thread

You must be logged in to reply to this topic.