I wanted to execute a function whenever a cell is edited or added in google spreadsheet.
I have the below function, but it is not working. please help. Also I wanted to call the function Start sync after X seconds. How to give a delay in calling the startSync()
function onEdit(e) {
var range = e.range;
range.setNote('Last modified: ' + new Date());
startSync()
}
whenever I edit a cell , a note (comment) is getting added to the cell , but the startSync is not getting called.
function startSync() {
//Get the currently active sheet
var sheet = SpreadsheetApp.getActiveSheet();
//Get the number of rows and columns which contain some content
var [rows, columns] = [sheet.getLastRow(), sheet.getLastColumn()];
//Get the data contained in those rows and columns as a 2 dimensional array
var data = sheet.getRange(1, 1, rows, columns).getValues();
syncMasterSheet(data);
}
Answer: Installable Triggers helped me to call StartSync()