Google Sheets OnEdit() - 您无权调用服务 [英] Google Sheets OnEdit() - You do not have permission to call a service

查看:25
本文介绍了Google Sheets OnEdit() - 您无权调用服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自本月初以来,此代码不再有效

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

推荐答案

onEdit() 必须是 Installable Trigger 因为它正在使用需要授权的服务.

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 脚本在发生特定事件(例如打开文档)时自动运行函数.然而,可安装的触发器比简单的触发器提供了更多的灵活性:它们可以调用需要授权的服务,...

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:

  1. 从脚本编辑器中,选择编辑">当前项目的触发器".
  2. 单击显示以下内容的链接:未设置触发器.单击此处立即添加一个.
  3. 在运行下,选择要触发的函数名称.
  4. 在事件下,选择时间驱动或脚本绑定到的 Google 应用(例如,来自电子表格).
  5. 选择并配置您要创建的触发器类型(例如,每小时运行的小时计时器或打开触发器).
  6. 或者,单击通知以配置在触发功能失败时通过电子邮件与您联系的方式和时间.
  7. 点击保存.

这篇关于Google Sheets OnEdit() - 您无权调用服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆