Google App script: You do not have permission to c

2019-07-16 16:15发布

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.

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!

2条回答
我只想做你的唯一
2楼-- · 2019-07-16 16:48

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.

查看更多
我命由我不由天
3楼-- · 2019-07-16 16:58

Are you logged into multiple Google accounts in the same browser?

Google Scripts insides may sometimes not work as expected when multiple accounts are authorized in the same browser session. Try logging out of all accounts except the one that owns the script.

查看更多
登录 后发表回答