SpreadsheetApp.getUi () operation not supported?

Trying to add a confirmation dialog when a user clicks on a menu item, I follow this Google page almost to the letter: https://developers.google.com/apps-script/guides/dialogs#alert_dialogs

However, I get an error "This operation is not supported." In Transcript, I see the following:

[14-02-10 12:21:54:551 EST] Starting execution
[14-02-10 12:21:55:550 EST] Execution failed: This operation is not supported (line 28, file "Code") [0.226 seconds total runtime]

Line 28 in the Code is the second line of the function below:

function sendMergedMail() {
  var ui = SpreadsheetApp.getUi();
  var result = ui.alert(
     'Please confirm',
     'Are you sure you want to continue?',
      ui.ButtonSet.YES_NO);
  if (result != ui.Button.YES) {
    return
  }

  var doc = SpreadsheetApp.getActiveSpreadsheet();
  doc.toast("Current sheet: "+doc.getName());
};

Thank!

+3
source share
1 answer

This code is for a new version of spreadsheets , have you upgraded to a new version?

(just tested and working without problems)

+1
source

All Articles