Google表格OnEdit() - 您无权调用showModalDialog [英] Google Sheets OnEdit() - You do not have permission to call showModalDialog
问题描述
从本月初开始,这段代码并没有更多的工作。
onEdit(e){
var html = HtmlService.createTemplateFromFile('MyHtmlFile')
.evaluate()
.setWidth(800)
.setHeight(400);
SpreadsheetApp.getUi()//或DocumentApp或FormApp。
.showModalDialog(html,'我的页面标题');
}
当我编辑电子表格的单元格没有弹出窗口时 strong>但我在控制台中发现错误:
Google Apps脚本:您没有权限调用showModalDialog
OnEdit()必须是可安装触发器,因为它使用的是需要授权的服务。
$ b 注意:在使用它作为可安装的触发器可能存在的问题
像简单触发器和可安装的触发器可让Apps脚本在发生某些事件(例如打开文档)时自动运行一个功能。然而,可安装的触发器比简单的触发器提供了更大的灵活性:它们可以调用需要授权的服务 ...
要通过脚本编辑器中的对话框手动创建可安装触发器,请执行以下步骤:
- 在脚本编辑器中,选择编辑>当前项目的触发器。
- 点击链接:没有设置触发器。点击此处立即添加一个。
- 在运行下,选择要触发的功能的名称。
- 在事件下,选择时间驱动或脚本绑定的Google App(例如,从电子表格)。
- 选择并配置要创建的触发器的类型(例如,运行Every的小时计时器小时或开启触发器)。
- 或者,点击通知,配置您的触发功能失败时您将如何以及何时通过电子邮件与您联系。 >点击保存。
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 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.
note: rename onEdit()
when using it as an installable trigger to avoid possible issues
Like simple triggers, installable triggers let Apps Script run a function automatically when a certain event, such as opening a document, occurs. Installable triggers, however, offer more flexibility than simple triggers: they can call services that require authorization, ...
To manually create an installable trigger through a dialog in the script editor, follow these steps:
- From the script editor, choose Edit > Current project's triggers.
- Click the link that says: No triggers set up. Click here to add one now.
- Under Run, select the name of function you want to trigger.
- Under Events, select either Time-driven or the Google App that the script is bound to (for example, From spreadsheet).
- Select and configure the type of trigger you want to create (for example, an Hour timer that runs Every hour or an On open trigger).
- Optionally, click Notifications to configure how and when you will be contacted by email if your triggered function fails.
- Click Save.
这篇关于Google表格OnEdit() - 您无权调用showModalDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!