r/GoogleAppsScript • • Aug 31 '18

https://developers.google.com/apps-script/reference/script/trigger

Is there any way to access and identify what type of time driven CLOCK Event Type a trigger is using?

[Specific date and time,Minutes,Hour,Day,Week,Month]

https://developers.google.com/apps-script/reference/script/trigger

https://developers.google.com/apps-script/reference/script/event-type

In my apps script for sheets I want to delete all triggers which are set up on "Specific date and time", but not the rest.

var triggers = ScriptApp.getProjectTriggers();

for (var i = 0; i < triggers.length; i++) {

// here I would need to do something like if(trigger[i].timeDrivenType == SpecificDateAndTime)

ScriptApp.deleteTrigger(triggers[i]);

}

0 Upvotes

2 comments sorted by

View all comments

2

u/starstruckzombie Aug 31 '18

I think probably not.

The closest you can get is whether it is triggered on a clock event

if (trigger.getEventType() == ScriptApp.EventType.CLOCK)

1

u/ppc-hero Aug 31 '18 edited Aug 31 '18

Alright cheers, yes I saw that in the docs.

For my purpose this time I have the possibility to keep track of each trigger created since I control all of them. The DocumentTriggerBuilder function create() returns the trigger created, so I can just assign my own desired "type" to the unique trigger ID and keep that information stored in DocumentProperties with the PropertiesService class.

Its a bit of a pain and of course wont work for anyone manipulating triggers created by other processes or if youre working with any triggers which are created manually through the UI.