Get all Google Script Triggers and remove them

Viewed 3235

Is there a way to get (and change/remove) all Triggers from all documents in Google Script, as if I opened Script Editor -> Edit -> All your triggers ?

Update:

I added a few test triggers and tried to loop all the spreadsheet files as it is said by Pierre-Marie Richard:

function getAllSpreadsheetTriggers()
{
    var files = DriveApp.getFilesByType('application/vnd.google-apps.spreadsheet'),
        spreadsheets = [],
        triggers     = [];

    while(files.hasNext())
        spreadsheets.push( SpreadsheetApp.openById(files.next().getId()) );

    for (var i = 0; i < spreadsheets.length; i++)
    {
        triggers = ScriptApp.getUserTriggers( spreadsheets[i] );
        Logger.log(triggers);
    }
}

But .getUserTriggers() always return an empty array. I read this issue, the last answer is "We decided not to take action on this issue. Triggers always belong to a particular script and are not accessible to other scripts. The documentation has been clarified to make this clear."

It turns out that can't it be done?

2 Answers
Related