I am using the onEdit trigger quite a bit in my scripts, and I realized that it can only be triggered from a ‘user’ edit. (“An installable edit trigger runs when a user modifies a value in a spreadsheet.”).
How can I go around this? I have a script that changes the value of a checkbox from false to true, and an edit trigger to perform an action if this checkbox is changed from false to true. The action is performed perfectly, when I MANUALLY (as in click the checkbox myself) set it to true. However, it does not work when the script changes the value to true (per documentation edit must be made by a user).
Is there a work around for something like this?
Below is the code that listens for an edit made to said checkbox.
function insertByTrigger (e){
let sheetName = e.source.getActiveSheet().getName();
let ss = SpreadsheetApp.getActiveSpreadsheet();
let editResults = e.source.getActiveSheet().getRange(1,27).getValue();
if(sheetName == "Checker" && editResults == true) {
ss.getSheetByName(sheetName).getRange(1,27).setBackground('red');
ss.getSheetByName(sheetName).getRange(1,27).setValue(false);
resumeIndex();
SpreadsheetApp.flush();
ss.getSheetByName(sheetName).getRange(1,27).setBackground('white');
console.log('cell was set to true, and then reverted to false');
}
else {
console.log('Non essential update made.')
}
}
This code works as intended when manually checked, but how can I get this to work when the results of another script set said checkbox to true?