Search code examples
google-apps-scriptgoogle-sheetsgoogle-apps-script-addonshowmodaldialogtriggers

You do not have permission to call showModalDialog


I am trying to code an add-on for my business domain. When I test the add-on with Enabled (auth.Limited) I get "You do not have permission to call showModalDialog / prompt" error in onOpen. I am logged as owner. Any idea why that happens ? I can't find anything in the docs.


Solution

  • The doc here explains everything:

    https://developers.google.com/apps-script/add-ons/lifecycle#opening

    When a document opens, it loads every add-on that the current user has installed or that any collaborator has enabled in the document, and calls each of their onOpen(e) functions.

    This means that your showModalDialog / prompt will open every time a user opens a document which is not allowed.

    If you really want to have a message for every time a document is open (users probably won't like this) then use a sidebar since in auth.Limited it is allowed, see the table here:

    https://developers.google.com/apps-script/add-ons/lifecycle#authorization_modes