如何触发Google Apps工作表的UI类? 我的目标我期望发生什么,而不是发生什么事情复制步骤。

我的目标

SqsAsyncClient

// Display a dialog box with a title,message,input field,and "Yes" and "No" buttons. The
// user can also close the dialog by clicking the close button in its title bar.
var ui = Spreadsheetapp.getUi();
var response = ui.prompt('Getting to know you','May I know your name?',ui.ButtonSet.YES_NO);

// Process the user's response.
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.');
}

我期望发生什么,而不是发生什么事情

我希望用户界面显示一个带有标题,消息,输入字段以及“是”和“否”按钮的对话框。用户还可以通过单击其标题栏中的关闭按钮来关闭对话框。

但是,什么也没发生。

复制步骤。

  1. 打开Goog​​le表格。
  2. 打开脚本编辑器:工具>脚本编辑器
  3. 将上述代码粘贴到脚本编辑器中。
  4. 关闭脚本编辑器。
  5. 导航到Google表格。

但是正如我提到的,实际上什么也没发生。

如何触发UI实例启动?我在做什么错了?

xjj070324why 回答:如何触发Google Apps工作表的UI类? 我的目标我期望发生什么,而不是发生什么事情复制步骤。

运行此功能:

function runIt() {
  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.');
  }
}

运行该功能后,请查看电子表格。

enter image description here

本文链接:https://www.f2er.com/3135495.html

大家都在问