该脚本适用于 sheet,但不是具有相同代码的插件

The script works from the sheet, but not as addon with the same code

该项目作为表格插件发布。受信任的测试人员(也是电子表格编辑器)启动了一个附加组件,但它不起作用。他收到消息 "You do not have access to perform that action. Please ask the owner of this item to grant access to you"。 如果编辑器使用相同的代码在同一个电子表格中启动内置脚本,那么一切正常。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sName = ss.getName();
var eds = ss.getEditors();
var owner = eds[0];
var ed = eds[1];
var sheet = ss.getSheetByName("Task");
var emailAddress = owner.getEmail();
var subject = "Done! - " + sName;
var localDate = Date();
sheet.getRange(12, 2, 1, 1).setValue(localDate);
var values = sheet.getRange("B2:K11").getValues();
var message = "#" + values + "#" + localDate + "#";
MailApp.sendEmail(emailAddress, subject, message);
ss.removeEditor(ed);

请告知在哪里挖掘。

安装插件不会授予插件的所有权限。它还需要启用。除非启用,否则已在 AuthMode.NONE 中发布附加组件 运行。尝试添加一个菜单项,然后 运行首先在其中启用该功能以在文档中启用它。