0
votes

Some time ago I wrote a script for one of my spreadsheets, that uses installable trigger onOpen to initiate SpreadsheetApp.getUi function.

The function looks like that:

function addMenu()
{
  // adding custom menu 
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('New menu')
  .addSubMenu(ui.createMenu('menu')                  
              .addItem('item', 'functionName')
              .addSubMenu(ui.createMenu('additive')
                          .addItem('subitem', 'subfunctionName')))
  .addToUi();
};

This menu worked like a charm using installable trigger onOpen being fired from spreadsheet. The functions called by these menu items use UserProperties, so I made sure this is not running anonymously.

This week I noticed that the menu no longer works when I open the spreadsheet - it only works if I call it directly from the script editor.

I have no idea how to fix this - I made no changes to the script, and checked to be sure nobody else did meddle with it. It's the same script that worked up until now.

I would very much appreciate the help on this one, it's puzzling to say the least.

Thanks!

1
Do you still have this issue? If so, add the execution transcript / logs.Rubén

1 Answers

0
votes

Are the submenus supposed to be nested inside each other? If not, you're probably looking for:

function addMenu() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('New menu')
    .addSubMenu(ui.createMenu('menu')                  
      .addItem('item', 'functionName')
    )
    .addSubMenu(ui.createMenu('additive')
      .addItem('subitem', 'subfunctionName')
    )
    .addToUi()
};