I have a boolean value on Spreadsheet Cell A1 and some content on B1 which I want to get cleared based on the boolean value BUT after 15 minutes of matching the boolean value.
Following is the code which I had created based on my research all over the Internet.
function boolean(value) {
var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
var value = sheet.getRange('A1:A6').getValue();
if (value=="Yes") {trigger15()};
}
function trigger15() {
ScriptApp.newTrigger("trigger15")
.timeBased()
.everyMinutes(15)
.create();
{clearRange()}
}
function clearRange() {
//replace 'Sheet1' with your actual sheet name
var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
sheet.getRange('B1:B6').clearContent();
}
The problems I'm facing:
- Instead of working after 15 minutes of condition matching, the trigger15 scripts creates many "15 minutes triggers" which eventually shows an error of "Too many triggers"
- The B1 cells get erased within 10 seconds and even if the A1 is not "Yes"
- One more thing, I'm struggling to do is: how can I use a single app script to apply this rule to further rows like A2 & B2, A3 & B3... So on.
What correction should I do to the script to make it work perfectly?
I recently started using App script so knows very basics. It would be helpful of you provide some resources for further digging.