1

I have created an addon using this guide.

code.gs

function onOpen() {
   SpreadsheetApp.getUi().createAddonMenu()
   .addItem('Start', 'showSidebar');
}

function showSidebar() {
  const ui = HtmlService.createHtmlOutputFromFile('index').setTitle('Sample');
  SpreadsheetApp.getUi().showSidebar(ui);
}

index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <h1>Works</h1>
  </body>
</html>

It says "If you switch back to document and reload you will see a submenu under Add-ons menu.

But I could not find my addon submenu, I think the quickstart guide is outdated.

Please guide me, How to test the addon on google sheet.

2

The problem is that the onOpen function is incomplete; .addToUi(); is missing.

This is the onOpen function on the referred guide

/**
 * Creates a menu entry in the Google Docs UI when the document is opened.
 * This method is only used by the regular add-on, and is never called by
 * the mobile add-on version.
 *
 * @param {object} e The event parameter for a simple onOpen trigger. To
 *     determine which authorization mode (ScriptApp.AuthMode) the trigger is
 *     running in, inspect e.authMode.
 */
function onOpen(e) {
  DocumentApp.getUi().createAddonMenu()
      .addItem('Start', 'showSidebar')
      .addToUi();
}
2
  • Fixed the issue but still, no menu is displayed. – Sameer Khan Feb 27 at 19:45
  • @SameerKhan Try using Chrome in incognito mode. If it still doesn't work, look at the script execution to see if there is an error and in such case please edit the question to include the textual error message. – Rubén Feb 27 at 21:21
1

Solved It

Found guidance from this article

In order to test

  1. Switch back to the legacy editor

  2. Select Run > Test as add-on

  3. Configure Test

    Select version: Test with latest code
    Installation Config: Choose any of the option
    Select Doc: Select your sheet
    Save

  4. Execute Saved Test > Test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.