1
votes

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.

1
What runtime are you currently using?Alessandro
I'm not sure I understand, but I have set the actual function I am trying to run for a variety of runtimes before it exits - 300 seconds, 200 seconds, and 50 seconds, just in case that was the issue (eg. the trigger time was overlapping with the runtime of the original function). However, none of them worked. What happened was each time it set the trigger and the trigger seemed to be valid in the Trigger List, however at execution time it failed with the above messagefungiblecommodity
@Alessandro is asking what runtime(environment in which the script is running)- v8 engine or old rhino engine?TheMaster

1 Answers