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 = "xyz@gmail.com";
MailApp.sendEmail(email, "TriggerMail", "hello");
installTrigger();
}
您需要在1分钟后设置触发器才能将其触发。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.