How to Stop Orphaned Triggers

2019-08-29 02:11发布

Interesting use case:
1. Script 1 with ScriptApp trigger management associated as an image link in a Google Site
2. Created a new instance of the script under a new account and update the image link
3. Deleted the container script 1 within the Google Site
4. A user visited the Google Site to invoke the script, but the page was cached pointing to the previous script 1.
5. The on-error trap emails are being emailed to me every time the "deleted" script runs.

How do I delete or stop these triggers?

3条回答
做个烂人
2楼-- · 2019-08-29 03:03

In the Script Editor, You can also check for a project's triggers programmatically, then work with that trigger and it's source:

// Get triggers  
var triggers = ScriptApp.getProjectTriggers();

// Loop through each trigger
triggers.forEach(function(trigger) {

    // Get the id
    var id = trigger.getTriggerSourceId();

    // You can then use that id to get the related form or a sheet. E.g. :
    var ss = SpreadSheetApp.openById(id);

    // You can also work with the trigger (i.e. delete it)
    ScriptApp.deleteTrigger(trigger);

  });

See https://developers.google.com/apps-script/reference/script/script-app for more

查看更多
做自己的国王
3楼-- · 2019-08-29 03:09

If you know the user that installed the trigger you could ask them to do to the "All my triggers" menu item in the script editor, find the trigger and delete it.

查看更多
疯言疯语
4楼-- · 2019-08-29 03:12

In the on-error email, there is a link to manage triggers. Make sure that the triggers are really gone. I had this issue with a set of shared spreadsheets, where I thought I had removed all the triggers, but my partner still had some enabled.

查看更多
登录 后发表回答