Search code examples
google-apps-scriptgoogle-docsadd-on

Google Docs add-on can't "start" from menu


I have written a Google Docs add-on that is installed in a Google Docs template.

For no apparent reason the add-on has stopped showing up in the add-ons menu in Google Docs, when creating a new document using the template where the add-on is installed.

I can see the add-on's submenu, but there is no "Start" option (as installed in the menu in main.gs)

Start item missing

function onOpen(e) {
    DocumentApp
        .getUi()
        .createAddonMenu()
        .addItem('Start', 'showSidebar')
        .addToUi();
}

Also the "Use" button on the add-ons side panel is grayed out, disabled.

Use button disabled

Both template and add-on are visible only to a G-suite organisation.

The problem began after adding Gmail functionality/permissions to the add-on, but I am not sure it is related, because rolling back those changes doesn't resolve the problem.

Also, I don't see any use case for the "Use" button being disabled, so I am wondering if it can be a bug in the add-ons system?

I can temporarily fix it by reinstalling the add-on, but when I create a new document, the problem returns.


Solution

  • Addressing your first question. I had this issue before. It relates to what code is being run in your code.gs file. You should have nothing in there that requests permissions before the side bar is open. For example it should not try to get the users email before the side bar has opened. There is more information here.