I have been trying to create a Google Apps Script which sets a trigger before time-out and continues after a set period of time.
The first trigger works properly, but the second trigger always fails to execute the code, with this error message "This trigger has been disabled for an unknown reason."
I stripped back the code to test this with the following:
function setTriggerTest() {
var triggers = ScriptApp.getProjectTriggers();
for ( var i in triggers ) {
//delete all previous triggers for this function
if (triggers[i].getHandlerFunction() == "setTriggerTest") {
ScriptApp.deleteTrigger(triggers[i])
}
}
var currTime = (new Date()).getTime();
//set a new trigger to launch this function in 10000 milliseconds
ScriptApp.newTrigger("setTriggerTest")
.timeBased()
.at(new Date(currTime+10000))
.create();
}
This code runs, then successfully sets up the next trigger, then runs the setTriggerTest() function again, then sets up another trigger. But then that second trigger fails to execute setTriggerTest(), with the error message "This trigger has been disabled for an unknown reason."
Is there any reason behind this and/or workaround? Basically I want to perform functions that take 15 minutes altogether so it needs to be split over three executions.