onSelectionChange Google App Script 根本不起作用

Gen*_*mes 3 google-sheets google-apps-script

我正在尝试根据当前选定的单元格更新 Google 表格中侧边栏的内容。我的第一个虚拟脚本是:

function onSelectionChange(e) {
  var ui = SpreadsheetApp.getUi();
  var range = e.range;
  var selectedRow = range.getNumRows();

  var htmlOutput = HtmlService
  .createHtmlOutput('This is row '+selectedRow)
  .setTitle('Title');
  ui.showSidebar(htmlOutput);
}
Run Code Online (Sandbox Code Playgroud)

...它什么都不做,即没有侧边栏显示。我试图停用应用程序脚本 v8,没有变化。

Tan*_*ike 6

在当前阶段,OnSelectionChange 事件触发器用作简单触发器。在这种情况下,不幸的是,侧边栏不能与此事件触发器一起使用,因为它需要授权。发生错误Exception: You do not have permission to call Ui.showSidebar. Required permissions: https://www.googleapis.com/auth/script.container.ui。不幸的是,这是当前的答案。

但是,我认为在未来的更新中,当 OnSelectionChange 事件触发器可以用作可安装触发器时,您的目标将能够实现。

为此,如何为问题跟踪器提出这个作为未来的请求?

参考: