How to implement a click handler with CardService?

Solution 1:

You can use the method updateCard(card)

This allows you to replace the card you built with a version where all check boxes are checked (that is se to true).

Sample:

function handleSelectAll(e) {
    
    var checkboxGroup = CardService.newSelectionInput()
        .setType(CardService.SelectionInputType.CHECK_BOX)
        .setTitle("A group of checkboxes. Multiple selections are allowed.")
        .setFieldName("checkbox_field")
        .addItem("checkbox one title", "checkbox_one_value", true)
        .addItem("checkbox two title", "checkbox_two_value", true)
        .addItem("checkbox three title", "checkbox_three_value", true);

    var section = CardService.newCardSection().addWidget(selectAll).addWidget(checkboxGroup)
    var card = CardService.newCardBuilder().addSection(section);

    return CardService.newNavigation().updateCard(card.build());
}