Search code examples
google-apps-scripttriggersmenugoogle-formsgoogle-apps-script-addon

Add-on menu doesn't get created when published through G-Suite Marketplace SDK, but does through Chrome Web Store


Whether by using createAddonMenu() or createMenu(), I can't create menu when add-on is installed through GSM, or when opened with "Integrate With Google" via G-Suite Marketplace SDK. "Test as add-on" via Script Editor works, installation via Chrome Web Store works, and I have no idea what might be wrong. I'm not sure if the script runs in the first place.

I've tried existing solutions from StackOverflow such as calling functions in different order, but nothing seems to work.

Does someone know what might prevent add-on/script from working with GSM?

Here's onOpen and onInstall functions I used.

function onOpen(e) {
  if(LOGENAB){console.log("onOpen...");}
  if(LOGENAB){console.log(e.authMode);}
  if(e && e.authMode == ScriptApp.AuthMode.NONE){
    // Authorization needed
    if(LOGENAB){console.log("# Authorization required!");}
    var ui = FormApp.getUi();
    var menu = ui.createMenu('title');
    menu.addItem('Authorize', 'authorizeAddon');
    menu.addToUi();
  } else {
    // Authorization not needed
    if(LOGENAB){console.log("# Authorization OK!");}
    var ui = FormApp.getUi();
    var menu = ui.createMenu('title');
   menu.addItem('Control Panel', 'showControlPanel');
   menu.addItem('About', 'showAbout');
   menu.addItem('Reset running status','toggleStatus');
   menu.addToUi();
  }
}
function onInstall(e) {
  if(LOGENAB){console.log("onInstall...");}
  onOpen(e);
}

Solution

  • Add-ons published as unlisted didn't show up in editor with older version of G-Suite services when installed through GSM. This appears to be fixed in current version of the service.