在附加到Google Spreadsheet的脚本中,我有一个自定义菜单项来启动/停止脚本。有条件地以实际状态存储在其他位置,我想更改提示窗口。问题在于,CardService.newButtonSet()
似乎为空,因此添加按钮会导致错误。
var state = true //Comes from DocumentProperties
var onButton = CardService.newTextButton().setText("Spustit")
var offButton = CardService.newTextButton().setText("Pozastavit")
var cancelButton = ui.Button.CANCEL
var buttonSet
if (state == "true"){
msg = "Do you want to stop the scripts?"
title = "Automatic update is on"
// Here I get the error: "Cannot find method addButton(Button)"
buttonSet = CardService.newButtonSet().addButton(offButton).addButton(cancelButton)
} else if (state == "false"){
msg = "Do you want allow the scripts"
title = "Automatic update is off"
buttonSet = CardService.newButtonSet().addButton(onButton).addButton(cancelButton)
} else {
msg = "Do you want to switch automation on or off?"
title = "Automation"
buttonSet = CardService.newButtonSet().addButton(onButton).addButton(offButton).addButton(cancelButton)
}
您有小费吗,怎么了?
答案 0 :(得分:1)
来自https://developers.google.com/apps-script/reference/card-service/
当前,您只能使用此服务来构建Gmail加载项。