2

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.

TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • What runtime are you currently using? – Alessandro Aug 31 '20 at 14:23
  • 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 message – fungiblecommodity Aug 31 '20 at 19:59
  • @Alessandro is asking what runtime(environment in which the script is running)- v8 engine or old rhino engine? – TheMaster Sep 01 '20 at 02:39

2 Answers2

4

This is a known issue and has been reported multiple times in the issue tracker. Consider adding a star(on top left) to these issues to let Google know you want them to prioritize the issue. For some, Reverting back to old rhino engine has resolved the issue.

Issues:

Related questions:

TheMaster
  • 45,448
  • 6
  • 62
  • 85
0

Noting that this is still unresolved (as are those four issues listed in the answer above from the IssueTracker) 18 months later (March 2022).

Gareth
  • 311
  • 3
  • 6