Nathan Graber
Nathan Graber

Reputation: 29

Test as Add-On Not Working

I am trying to create a script for Google Sheets. I have created a script and am attempting to "test as add-on" but it doesn't seem to be doing anything when I 'test' it. I pulled this code from developers.google.com and it's a simple script that creates a custom menu. When I attempt to test it, the sheet opens but nothing happens. The custom menu is not showing up. Any suggestions? Thanks in advance...

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Custom Menu')
    .addItem('First item', 'menuItem1')
    .addSeparator()
    .addSubMenu(ui.createMenu('Sub-menu')
      .addItem('Second item', 'menuItem2'))
    .addToUi();
}

function menuItem1() {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
    .alert('You clicked the first menu item!');
}

function menuItem2() {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
    .alert('You clicked the second menu item!');
}

Upvotes: 1

Views: 371

Answers (1)

Nathan Graber
Nathan Graber

Reputation: 29

Disregard... I was looking at the Menu bar and didn't realize it was listed under Add-Ons (I noticed on an old one I had tested, it was listed on the menu bar and NOT under add-ons, hence the reason I didn't check there).

Upvotes: 1

Related Questions