我有一个应用程序脚本项目,我使用一个库来控制多个电子表格(每个用户一个)。这允许我将所有代码保存在一个地方,供许多用户使用。
每个用户的电子表格都有一个可安装的触发器(编辑时),该触发器作为具有授权的单个用户运行,并从库中调用函数。
我现在犯了一个错误,我以前没有:
“您没有调用showModalDialog的权限”
showModalDialog
确实在库中使用,以使用电子表格向用户发送警报。我正在使用
showModalDialog
而不是
ui.alert()
因为
用户界面。警报()
当用户在5分钟后没有响应时,停止代码并抛出错误(假设他们离开了计算机)。这之前是可行的,但最近停止了。为什么?
我的脚本文件包括以下作用域:
https://www.googleapis.com/auth/script.container.ui
https://www.googleapis.com/auth/script.external_request
https://www.googleapis.com/auth/script.send_mail
https://www.googleapis.com/auth/spreadsheets
以下是用户绑定脚本中的代码:
function userEdited(e) {
Library.userEdited(e);
}
用户绑定脚本有一个可安装的触发器,该触发器通过“On edit”事件运行“userEdited”。
以下是库脚本中的代码:
function userEdited(e){
alert("the dialogue works");
}
function alert(message){
var htmlOutput = HtmlService
.createHtmlOutput('<p>' + message + '</p>')
.setWidth(300)
.setHeight(message.length / 50 * 25 + 30);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, "HAL 9000");
}