如何管理来自非 Apps 脚本代码的表单响应电子表格(例如 Node.js)

How to manage form responses spreadsheet from non-Apps Script code (Node.js for example)

我正在尝试创建一个 Google 管理批准工作流的表单插件

想法是这样的:

User A will be the owner of the Form Responses spreadsheet.

(there might be other recipients such as Y, Z, ... in the workflow, but for simplicity, let's assume that there is only 1 recipient X)

This page is a normal webpage that is built with non-Apps Script code (for example Nodejs + React)


The question is: How a non-Apps Script code can modify the Form Responses spreadsheet?

据我了解,在这种情况下,只有两件事可以修改表单回复电子表格:

  1. 表单插件代码
  2. Forms Responses 电子表格(目标电子表格)的绑定脚本

但这是一个 Forms 插件,因此没有针对目标电子表格的绑定脚本,因此只有选项 1. The Forms add-on code 可行

=> There must be a way so that non-Apps Script code can notify The Forms add-on code to update the spreadsheet


这是我目前的解决方案(仍然不够好):

  1. 我会将工作流数据(配置、响应)存储在 Firebase Cloud Firestore(一个实时文档数据库,就像 MongoDB 和 Firebase 实时数据库的组合)

  2. 收件人每次 approved/rejected 请求时,我的 non-Apps Script 代码将更新 Firestore 上的数据

  3. 我的表单附加代码将侦听 Firestore 上的更改并相应地更新电子表格

I said that this solution is still not good enough because as you can check my another question here Google Apps Script - How to listen for realtime updates in Firebase Cloud Firestore?

=> At the moment, there might be no way for Apps Script to listen to realtime update on Firestore

=> The workaround is to use a time-based trigger to periodically check for new data on Firestore (but can only do once per hour at most because of the Apps Script quotas)

=> Once per hour to see new updates in the destination spreadsheet is not a good UX for users, it should be realtime)


知道如何在没有 once per hour limit 的情况下解决这个问题吗?

The question is: How a non-Apps Script code can modify the Form Responses spreadsheet?

(正如 TheMaster 在评论中提到的)使用 Google Sheets API.


=> There must be a way so that non-Apps Script code can notify The Forms add-on code to update the spreadsheet

是的,实际上是有的。你可以:

  1. 创建一个列出 HTTP POST 请求的 Web 应用程序作为表单插件的一部分有关详细信息,请参阅 https://developers.google.com/apps-script/guides/web
  2. 使用 Apps 脚本 API 从您的表单插件执行功能。有关详细信息,请参阅 https://developers.google.com/apps-script/api/how-tos/execute

相关