Home > OS >  How to remove an Extensions submenu item in Google Sheets?
How to remove an Extensions submenu item in Google Sheets?

Time:08-29

I am using the following code in my Apps Script Editor Add-On to add a menu item:

function onInstall(e) {
  onOpen();
}

function onOpen() {
  var ui = SpreadsheetApp.getUi()
  ui
  .createAddonMenu()
  .addItem("Open Search Sidebar", "createAndShowSidebarContent")
  .addToUi();
}

While I was developing the add-on, the code added a sub-menu item under Extensions as:

sheet-name --> Open Search Sidebar

Now that I have the add-on approved and in Google Workspace Marketplace, a second sub-menu item was added to Extensions as:

addon-name --> Open Search Sidebar

My question is how do I get rid of the original menu item "sheet-name --> Open Search Sidebar"?

[ The only SO answer that I found for removing menu items is this: https://stackoverflow.com/a/60179904/1978840 which is not viable for the Extensions menu. ]

CodePudding user response:

This menu "duplication" happens only in the add-on container.

It's not possible to remove the menu "sheet-name" when it belongs to an add-on contained by the spreadsheet when the add-on use createAddonMenu. You might replace this menu by createMenu, but then container will get a new menu next to the built-in menus. Knowing this, the next time you might want to use a stand-alone project for your add-ons.

In the meantime, the best that you can do is to use the container only for testing your add-on, using the sheet-name menu to test the last changes (head deployment).

CodePudding user response:

I think that the correct answer is to remove the Apps Script code for the Google Sheet and then have a bit of patience and the menu item will go away!

That's what happened 2 days after I installed the Add-On.

  • Related