Google App脚本:您没有通话提示权限 [英] Google App script: You do not have permission to call prompt

查看:75
本文介绍了Google App脚本:您没有通话提示权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Google脚本,该脚本显示了一个提示对话框,供您在编辑列时写评论.由于某些原因,这仅适用于我的电子邮件(脚本的创建者),但不适用于我共享电子表格的其他用户.当我使用其他用户帐户打开脚本编辑器时,我可以在视图->执行记录中看到错误:执行失败:您没有呼叫提示的权限.

I have created a google script that show me a prompt dialog to write a comment when a column is edited. For some reason this only works with my email (script's creator), but with the other users that I have shared the spreadsheet don't work. When I open the script editor with other user accounts I can see the error in the View -> Execution Transcript: Execution failed: You do not have permission to call prompt.

我的脚本函数的名称为"sendManualEmail",并且在事件->来自电子表格->编辑时

My script function has a name "sendManualEmail" and I already have the trigger created when Event -> From spreadsheet -> On edit

我什至只为该脚本创建了一个新项目,并询问了使用我的帐户发送电子邮件的权限,但对其他用户仍然无效.我已经阅读了同一问题的其他类似主题,但仍然无法修复我的问题.因此,预先感谢您的任何评论!

I even created a new project for only that script and asked me the permissions to send emails with my account, but still not working for other users. I have read some other similar topic with same issue but I am still not able to fix mine. So thanks in advance for any comment!

推荐答案

您需要用户授权您的脚本.为此,创建一个在onOpen()上激活的菜单.单击后,发送一个消息框,以确保您的用户必须授权您的脚本才能查看该消息.

You need your users to authorize your script. To do that, create a menu that activates on onOpen(). When clicked, send a message box, ensuring your users have to authorize your scripts to see the message.

在脚本顶部粘贴以下内容:

Paste the following at the top of your script:

/** @OnlyCurrentDoc */
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('myName') // your name
  .addItem("Activate myName's script", 'activateMyStuff')
  .addToUi();
}

function activateMyStuff() {
  browser.msgBox('Script is activated! thanks.');
}

重要提示:当您的用户单击菜单时,还将提示他们授权您的脚本以及脚本页面上的所有权限.确保清理该脚本,否则您的用户可能不得不授权奇怪的事情,而可能不会.请使用备用电子邮件地址对其进行测试,以查看其他人会看到什么.

Important: when your users click the menu, they will also be prompted to authorize your scripts and all the permissions on the script's page. Make sure you clean up that script, otherwise your users may have to authorize weird things - and likely won't. Do test it with an alternate email address to see what others will see.

最后,考虑将脚本发布为插件.它将使您的用户更轻松地授权和使用您的作品.

Lastly, consider publishing your script as an addon instead. It will make it that much easier for your users to authorize and use your work.

这篇关于Google App脚本:您没有通话提示权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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