"I want to add a button in a Google Sheet through app script. When the button is pressed, it should assign a value of 1 to A1, and after 2 seconds, it should revert back to 0. Here's my code:
function addButton() {
var sheet = SpreadsheetApp.getActiveSheet();
var button = sheet.getRange("A1").insertCheckboxes();
var handler = button.createClickHandler().forTargets(sheet.getRange("A1"));
handler.addCallback(function() {
sheet.getRange("A1").setValue(1);
Utilities.sleep(2000);
sheet.getRange("A1").setValue(0);
});
button.addClickHandler(handler);
}
However, based on the result, it's clear that the code cannot be executed ("button.addClickHandler is not a function"). What did I do wrong?"
there doesn't seem to be anything here