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

查看:69
本文介绍了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()必须是

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:

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

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

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