【问题标题】:Run Apps Script Client Side on Google Form Submit在 Google 表单提交上运行 Apps 脚本客户端
【发布时间】:2020-07-30 19:21:42
【问题描述】:

我目前正在尝试使用谷歌表单和应用程序脚本制作文书工作向导。在表单的末尾,一旦表单提交并显示 HTML 窗口,我将尝试运行 Apps 脚本。我尝试将FormApp.getUI()与应用程序事件触发器一起使用,但我不断收到错误Exception: Cannot call FormApp.getUi() from this context. 从其他帖子看来这个错误是因为触发器运行脚本服务器端。有没有办法在客户端运行这个脚本以便显示 HTML 窗口?

编辑:Conditional Sections Google forms 这个问题与我现在问的不同。

EDIT2:代码

代码.gs

function myFunction() {
  var lock = LockService.getScriptLock();

  var html = HtmlService.createHtmlOutputFromFile('display');
    FormApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
    .showModalDialog(html, " Let's check if you need to present!");
    SpreadsheetApp.flush();
    lock.releaseLock();
}

display.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <p>Test</p>
  </body>
</html>

【问题讨论】:

  • 如果您阅读了 getUi() Returns an instance of the form editor's user-interface environment that allows the script to add features like menus, dialogs, and sidebars. 的文档,那么您可以从中看到 ui 不适用于表单,而仅用于编辑表单。您没有任何可用于与 google 表单交互的客户端事件。您可以使用网络应用程序做您想做的事情。

标签: google-apps-script google-forms


【解决方案1】:

来自问题:

在表单的末尾,一旦表单提交并显示 HTML 窗口,我将尝试运行 Apps 脚本。

这是不可能的。

如果您收集了受访者的电子邮件地址,您可以向他们发送电子邮件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多