google-apps-script - 不支持 SpreadsheetApp.getUi() 操作?

标签 google-apps-script

试图在用户单击菜单项时添加确认对话框,我几乎完全按照这个 Google 页面进行操作:https://developers.google.com/apps-script/guides/dialogs#alert_dialogs

但是,我收到“不支持此操作”的错误消息。在执行记录中,我看到了这个:

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

谢谢!

最佳答案

此代码适用于 new version of spreadsheets ,你升级到新版本了吗?

(刚刚测试,没有问题)

关于google-apps-script - 不支持 SpreadsheetApp.getUi() 操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21684229/

相关文章:

google-apps-script - 从 Google 文档中的两个不同表中删除行很困难

google-apps-script - 自动将带有 Gmail 标签的电子邮件转换为 PDF 并将其发送到电子邮件地址

google-apps-script - Google 文档中的标题部分

javascript - 尝试使用需要身份验证的 API 使用 Google 脚本从 TDAmeritrade 提取股票报价信息

google-apps-script - Google Apps 脚本可根据另一个工作表中的单个 TRUE/FALSE 单元格清除范围

javascript - Google Apps 脚本 PropertiesService 访问冲突

google-apps-script - 将addRows()中的电子表格数据作为数组传递

time - 如何使用 google apps 脚本在 googlespreadsheet 中读取时间?

javascript - 获取子节点时 XML Null

google-apps-script - 谷歌应用脚​​本: Assign zero for empty cells