Unable to delete triggers (google-apps-script)

前端 未结 3 1333
醉酒成梦
醉酒成梦 2021-01-06 05:33

I appear to have triggers that I cannot delete in my Google Apps Script. I have a theory as to WHY I cannot delete them, but no clue how to fix the problem. These triggers w

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-06 05:49

    You could try to find out more about the script's container document. You can check for edit URLs and for users. If the document was not bound to a container, you could access the sharing information from the menu. If you are the last person to use the script, you could also copy the script and delete the original script - manually or as a document. But take care of any dependencies like script properties.

    I wrote a short loop to log information about container Url and its viewers:

    function containerFinder() {
      if (DocumentApp.getActiveDocument()) { 
        var document = DocumentApp.getActiveDocument();
        var editUrl = document.getUrl();
        var editors = document.getViewers();
        Logger.log("This Script belongs to a document.");
        Logger.log("Edit Url: " + editUrl);
        Logger.log("Editors: " + editors);
      }
      else if (SpreadsheetApp.getActiveSpreadsheet()){
        var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
        var editUrl = spreadsheet.getUrl();
        var editors = spreadsheet.getEditors();
        Logger.log("This Script belongs to a spreadsheet.");
        Logger.log("Edit Url: " + editUrl);
        Logger.log("Editors: " + editors);
      }
      else if (FormApp.getActiveForm()){
        var form = FormApp.getActiveForm();
        var editUrl = form.getEditUrl();
        var editors = form.getEditors();
        Logger.log("This Script belongs to a form.");
        Logger.log("Edit Url: " + editUrl);
        Logger.log("Editors: " + editors);
      }
      else {
        Logger.log("This Script does not seem to belong to any container.");
      }
    }
    

提交回复
热议问题