【发布时间】:2020-11-20 03:07:44
【问题描述】:
我对在谷歌表格上创建函数非常陌生,因此我在努力创建从弹出表单返回值的代码。 我一直在使用 Google Apps Script 中的这段代码:
var ui = SpreadsheetApp.getUi();
var response = ui.prompt('Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO);
if (response.getSelectedButton() == ui.Button.YES) {
Logger.log('The user\'s name is %s.', response.getResponseText());
} else if (response.getSelectedButton() == ui.Button.NO) {
Logger.log('The user didn\'t want to provide a name.');
} else {
Logger.log('The user clicked the close button in the dialog\'s title bar.');
}
并且想知道是否有办法将 response.getResponseText 返回到单元格。 当我使用“logger.log”部分所在的“return”函数时,我不断收到错误 - 'Cannot call SpreadsheetApp.getUi() from this context'
在编辑此脚本时是否有另一种方法,或者我应该以不同的方式解释为用户交互获取弹出表单。
谢谢
【问题讨论】:
标签: google-apps-script google-sheets-custom-function