Home > Software design >  Can the function called by ScriptApp.newTrigger identify the triggerID?
Can the function called by ScriptApp.newTrigger identify the triggerID?

Time:05-24

In my app script web app I have multiple triggers created with ScriptApp.newTrigger()

example:

function createTimeTriggerSpecifcDate(dateStr) {
  const date = new Date(dateStr);
  const trigger = ScriptApp.newTrigger("scriptToRunAt")
   .timeBased()
   .at(date)
   .create();
  return trigger.getUniqueId();
}

function scriptToRunAt(){
 ....
}

Is there a way for the called function "scriptToRunAt()" to know the trigger id?

thanks.

CodePudding user response:

The event object provides the triggerUid:

function scriptToRunAt(eventObject){
 const uniqueId = eventObject.triggerUid;
}
  • Related