Standalone script won't add custom menus

Viewed 27

Following the Guide as well as the documentation on createMenu and addMenu, I'm trying to add a custom menu to my Spreadsheet, like so:

function onOpen() {
  SpreadsheetApp.getUi()
   .createMenu('Test Menu')
   .addItem('foo', 'bar')
   .addToUi();

  SpreadsheetApp.getActiveSpreadsheet()
   .addMenu('Test Menu 2', [{ name: 'foo', functionName: 'bar' }]);
}

I wrote this as a standalone Apps Script project, and I'm deploying it via a Test Deployment from the Deploy drop down: Deploy -> Test Deployments -> Add test -> Installed and Enabled, selected a Spreadsheet file in my Google Drive. When I then click on Execute, the Spreadsheet opens, but the menus don't show. There is no error in the log. What gives?

enter image description here enter image description here

I know that adding menus requires binding the script to a document, and I'm assuming that associating the file in the Test Deployment dialog does that. For what it's worth, the bound script methods like SpreadsheetApp.getActiveSpreadsheet() didn't throw exceptions, so I assume the binding worked.

I have not modified the appscript.json file from its defaults. In another test I tried adding OAuth scopes for spreadsheets, but that didn't make a difference in the behavior described in this post.

0 Answers
Related