I am very new in google app script and script writing in general.
I have two function function Pops() and function Tiger()
Function Pops is triggered on form Submit
I want function Tiger() to run 60 seconds after the function Pops() completed its action.
CodePudding user response:
You can programmatically create a new time-based trigger with ScriptApp.newTrigger( functionName )
function Pops(){
// your logic goes here
ScriptApp.newTrigger( 'Tiger' ).timeBased().after( 60 * 1000 ).create();
}
function Tiger( event ){
// your logic goes here
// remove this trigger
if ( ( event.triggerUid || '' ).length ) {
var triggers = ScriptApp.getProjectTriggers();
for ( var trigger of triggers ) {
if ( trigger.getUniqueId() === event.triggerUid ) {
ScriptApp.deleteTrigger( trigger );
break;
}
}
}
}