CqN
CqN

Reputation: 283

How to find which of my google sheet scripts have any timed trigger

I have many projects,some of them very very larg (covid-19 related research) a few with timed triggers. Over time, I have made copies of scripts, renamed, and continued with the copy, adding timed triggers. I know I need to delete the triggers from the discontinued (but archived previously running) version of the script. But occasionally I would forget.

Is there a way for me to search my drive among all the google sheets and lists all those which have any timed triggers?

Upvotes: 0

Views: 99

Answers (1)

Cooper
Cooper

Reputation: 64042

You can use Drive.Files.list(); to find all of your project files.

GS:

function getScriptNamesTheHaveTimeBasedTriggerInCurrentProject() {
  Logger.log(ScriptApp.getProjectTriggers().map(t => {
    if (t.getEventType() == ScriptApp.EventType.CLOCK) {
      return t.getHandlerFunction();
    }
  }).filter(e => e).join(','));
}

If you had a script like this inside of each project you might be able to execute it from App Script API but you would have to select some external location to store the final output. I'm not a 100% sure that it would work because I've never tried it. In my case I have about 700 projects but I hardly ever you triggers so I don't have any real interest in attempting such a thing.

Upvotes: 1

Related Questions