Search code examples
google-apps-scriptgoogle-sheetsgoogle-sheets-api

Menu Items not appearing after deploying google App Script as Sheets Add-On


I have developed a script and deployed & published it as Add-On, this is internal app. I am able to see Add-On in Sheets, but only main menu is visible. Menu items created in onOpen(e) are not visible.

These menu's are visible when I performed testing but not working only while installing in another user.

I guess I am missing something in deployment. Can someone help me with the same?

Step1: I clicked on Publish-->Deploy as add-on--> got message as "You must configure the G Suite Marketplace SDK to publish an add-on.".

Step2: I went to GCP, enabled G Suite Marketplace SDK from APIs. Provided all details in configuration and Publish and clicked on Publish.

Step3: Now, the Add-On is visible in GSuite market and able to install it. But only Main menu is appearing, sub menu's inside it are not appearing.

function onInstall(e) {
  onOpen(e);
}  

function onOpen(e) {

    var menu = SpreadsheetApp.getUi().createAddonMenu(); // Or DocumentApp.
    if (e && e.authMode == ScriptApp.AuthMode.NONE) {
        // Add a normal menu item (works in all authorization modes).
        menu.addItem('Submit to Level1', 'P_Level1');
        menu.addSeparator();
        menu.addItem('Submit to Level2', 'P_Level2');
    } else {
        // Add a menu item based on properties (doesn't work in AuthMode.NONE).
        var properties = PropertiesService.getDocumentProperties();
        var workflowStarted = properties.getProperty('workflowStarted');
        if (workflowStarted) {
        menu.addItem('Submit to Level1', 'P_Level1');
        menu.addSeparator();
        menu.addItem('Submit to Level2', 'P_Level2');
        } else {
        menu.addItem('Submit to Level1', 'P_Level1');
        menu.addSeparator();
        menu.addItem('Submit to Level2', 'P_Level2');
        }
        menu.addToUi();
    }
}

Regards, Sai Krishna.


Solution

  • This is working fine. The Steps I have mentioned are corrected.

    It did not work as I have given Script ID in below Input box. I changed it to "Project key (Deprecated)" and it worked fine.

    Thank You all for your inputs.

    enter image description here