HTML Service does not open a sidebar in V8 runtime

感情迁移 提交于 2020-07-09 13:24:26

问题


I have a very large project running on Rhino, but when I switch it to V8 one of the basic functionalities break - the sidebar in Google Sheets can no longer be opened.

Basic architecture:

A) Google Sheet A with a script (Rhino) importing a GAS Library (V8). The sidebar is in the Library.

versus

B) Google Sheet B with a script (V8) importing a GAS Library (V8). The sidebar is in the Library.


This code is in the Library (standalone script file, running in V8):

// called from parent script as LIB.showSidebar()
function showSidebar() {
  try {
    var ui = HtmlService.createTemplateFromFile("sidebar/sidebarClient.html")
      .evaluate()
      .setTitle("tools sidebar");
    SpreadsheetApp.getUi().showSidebar(ui);
  } catch (error) {
    var ui = SpreadsheetApp.getUi();
    ui.alert("Couldn't render sidebar: " + error);
    return;
  }
}

The previous library function is ran from the parent Sheet A/B script via the "LIB" namespace descriptor:

// simple trigger
function onOpen(e) {
  buildMenu();
}

//  builds menu
function buildMenu() {
  SpreadsheetApp.getUi()
    .createMenu("My menu")
    .addItem("Open sidebar", "openSidebar")
    .addToUi();
}

// opens sidebar
function openSidebar() {
  LIB.showSidebar();
}

Behavior:

A) Everything works fine, the code above opens up the Sidebar in Sheet A as expected.

B) The result is an alert showing:

"Couldn't render sidebar: Exception: Not found."

Switching the script in Sheet B back to Rhino solves the issue, and the Sidebar opens in Sheet B too.

Therefore, the issue is the switch to V8.

Is the filename in the form of a path the issue on V8 ("sidebar/sidebarClient.html")? I'm using clasp to sync files into subfolders - it's really a huge project and I can't (or rather refuse to) do without that.


I tried using the filename with and without the .html extension, and with and without the path. The behavior is the same (all variations of the file path "sidebar/sidebarClient", "sidebar/sidebarClient.html", "sidebarClient" and "sidebarClient.html" behave the same, opening in sheet A, not found in sheet B).

Anyone got any ideas what might be going on?


回答1:


I also opened an issue on Google's Issue Tracker, currently still unresolved: https://issuetracker.google.com/issues/150054572



来源:https://stackoverflow.com/questions/60356124/html-service-does-not-open-a-sidebar-in-v8-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!