Check all checkboxes

This sample code checks and unchecks all choices of a checkbox field.

Sample Image

checkuncheck.gif

Sample Code

// Check/uncheck all checkbox choices

(function() {
    "use strict";

    var CHECKALL = 'check_all'; // Field code of checkbox to check/uncheck all checkboxes
    var CHECKBOX = 'mycheckbox'; //Field code of checkbox to have all choices checked/unchecked

    var events = ["app.record.create.change." + CHECKALL, "app.record.edit.change." + CHECKALL];

    kintone.events.on(events, function(event) {
        var record = event.record;
        var changes = event.changes.field.value;

        if (changes[0] === "check all") {
            record[CHECKBOX].value = ["sample1", "sample2", "sample3", "sample4", "sample5"];
        } else {
            record[CHECKBOX].value = [];
        }
        return event;
    });
}());

Notes

Make sure to match the Field code your fields, with the Field code written in the code.

 

Refer to the Tutorial page, on how to add scripts to your app.

Was this article helpful?
0 out of 0 found this helpful
Comments
Please sign in to leave a comment.