Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpreadsheetApp.getUi() operation not supported?

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

However, I am getting a "This operation is not supported" error message. In the Execution Transcript, I see this:

[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 "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 you!

like image 949
Wei Wang Avatar asked Dec 05 '25 04:12

Wei Wang


1 Answers

This code is for the new version of spreadsheets, did you upgrade to new version ?

(just tested and works without issue)

like image 182
Serge insas Avatar answered Dec 08 '25 03:12

Serge insas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!