试图在用户单击菜单项时添加确认对话框,我几乎完全按照这个 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/