1
votes

I have trouble with a time based trigger, which installs another time based trigger after work. I use this concept to split the work. Unfortunately the installed trigger never runs, but it is created.

The following code illustrates the concept:

function start() {
  installTrigger();
}

function installTrigger(){
  deleteClockBasedTriggers(); 
  ScriptApp.newTrigger("sendMail").timeBased().after(5000).create();
}

function deleteClockBasedTriggers(){
  var projectTriggers =  ScriptApp.getProjectTriggers();
  for(var i=0; i<projectTriggers.length; i++){
    if(projectTriggers[i].getEventType() == ScriptApp.EventType.CLOCK){
      ScriptApp.deleteTrigger(projectTriggers[i]); 
    }
  }
}

function sendMail(){
  var email = "[email protected]";
  MailApp.sendEmail(email, "TriggerMail", "hello");
  installTrigger();
}
1
This is working for me. Have you followed all the steps mentioned in this video?pointNclick

1 Answers

1
votes

You need to set trigger after 1 minute to get it fired.