我有一个回复谷歌电子表格连接到谷歌表格 .
在我有电子表格绑定脚本和onOpen像这样:
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.createMenu('Configura Gestione NC')
.addItem('Invio eMail', 'openDialog1')
.addToUi();
}
function openDialog1() {
var ui = SpreadsheetApp.getUi();
var response = ui.prompt('Inserisci la mail che riceverà tutte le comunicazioni:', 'Valore attuale: ' + PropertiesService.getScriptProperties().getProperty('emailSupervisore'), ui.ButtonSet.OK_CANCEL);
if (response.getSelectedButton() == ui.Button.OK) {
PropertiesService.getScriptProperties().setProperty('emailSupervisore', response.getResponseText());
}
}
myScript(e){
var SS = SpreadsheetApp.getActiveSpreadsheet();
and do other things
}
我在提交表单时运行的myScript(e)函数上设置了一个可安装的触发器,因为我需要截取表单响应 . 当我填写并发送表单时,我收到错误:
Cannot call SpreadsheetApp.getUi() from this context.
即使在myScript(e)上设置了触发器,也会运行onOpen吗?
在我的myScript(e)中,我不调用SpreadsheetApp.getUi()...即使在脚本中也会自动调用onOpen?
是否有一个解决方法,使SS Custom Menus和myScript功能一起工作?