不支持SpreadsheetApp.getUi()操作?

时间:2014-02-10 17:40:38

标签: google-apps-script

当用户点击菜单项时尝试添加确认对话框,我正在关注此Google页面几乎写到:https://developers.google.com/apps-script/guides/dialogs#alert_dialogs

但是,我收到“不支持此操作”错误消息。在Execution Transcript中,我看到了:

[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]

“代码”中的第28行是以下函数的第二行:

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());
};

谢谢!

1 个答案:

答案 0 :(得分:1)

此代码适用于new version of spreadsheets,您是否升级到新版本?

(刚刚测试过,没有问题)

相关问题