I would like to run a script on a daily trigger in google sheets. The script should first check if cell "A1" of Sheet1 has the value "DO NOT RUN" - then it should wait 30 minutes before running again (the value in A1 should change by then due to another script).
The script should not run more than once per day.
CodePudding user response:
If the value of A1 will be changed by another script, it might be better to make the other script to create a time-driven trigger set to be run after the desired time.
const action = 'put here the name of the function';
const minutes = 30;
const trigger = ScriptApp.newTrigger(action)
.timeBased()
.after(minutes * 60 * 1000)
.create();
Notes:
- You might use the Properties Service to manage a flag to control if the trigger for certain date was already create / or if the function was already executed.
- You should have to implement a method to delete the old triggers. This could be done by the function called by the trigger.
Related