Google Sheets OnEdit()-您无权调用服务 [英] Google Sheets OnEdit() - You do not have permission to call a service
问题描述
自本月初以来,此代码不再有效
Since the beginning of this month this code has not more been working
function onEdit(e){
var html = HtmlService.createTemplateFromFile( 'MyHtmlFile' )
.evaluate()
.setWidth( 800 )
.setHeight( 400 );
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog( html, 'My page title' );
}
当我编辑电子表格的单元格时,未显示弹出窗口,但是我在控制台中遇到此错误:
When I edit a Spreadsheet's cell NO pop up is shown but I got this error in the console:
Google Apps脚本:您无权调用showModalDialog
Google Apps Script: You do not have permission to call showModalDialog
推荐答案
The onEdit()
will have to be an Installable Trigger because it is using a service that requires authorization.
注释:将其用作可安装触发器时,请重命名 onEdit()
以避免
note: rename onEdit()
when using it as an installable trigger to avoid possible issues
类似于简单触发器,可安装触发器使Apps Script在发生某些事件(例如打开文档)时自动运行功能.但是,可安装的触发器比简单的触发器具有更大的灵活性:它们可以调用需要授权的服务,...
要通过脚本编辑器中的对话框手动创建可安装的触发器,请按照下列步骤操作:
To manually create an installable trigger through a dialog in the script editor, follow these steps:
- 从脚本编辑器中,选择编辑">当前项目的触发器".
- 单击显示以下链接:没有设置触发器.单击此处立即添加一个.
- 在运行"下,选择要触发的功能的名称.
- 在事件"下,选择时间驱动或脚本绑定到的Google App(例如,从电子表格中).
- 选择并配置要创建的触发器的类型(例如,每小时运行一个小时计时器或一个打开时触发的触发器).
- (可选)单击通知"以配置触发功能失败时通过电子邮件与您联系的方式和时间.
- 点击保存.
这篇关于Google Sheets OnEdit()-您无权调用服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!