Google App script: You do not have permission to call prompt

前端 未结 2 1726
猫巷女王i
猫巷女王i 2021-01-14 11:59

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), bu

相关标签:
2条回答
  • 2021-01-14 12:57

    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.

    0 讨论(0)
  • 2021-01-14 13:00

    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.

    0 讨论(0)
提交回复
热议问题