I'm trying to create a Google Forms add-on that manages approval workflows
Here is the idea:
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)
User B is the respondent, he goes to the form URL and submits a response (this is a request that will be approved/rejected by user X)
After user B submits a request, an email will be sent to user X's Gmail
In this email, there are 1 button: Approve/Reject this request
After user X clicks this button, a new tab is opened. And in this new page, user X can click 2 buttons Approve
or Reject
to give his feedback on the request of user B
This page is a normal webpage that is built with
non-Apps Script
code (for example Nodejs + React)
An email will be sent to both users B and X to tell them that the request is approved/rejected
Finally, in the Form Responses spreadsheet of user A (who installed and configured the add-on), the Approve/Reject status of the request will be updated accordingly
The question is: How a
non-Apps Script
code can modify the Form Responses spreadsheet?
From my understanding, in this case, there are only 2 things that can modify the Form Responses spreadsheet:
But this is a Forms add-on, so there is no bounded script for the destination spreadsheet, so only option 1. The Forms add-on code
is feasible
=> There must be a way so that
non-Apps Script
code can notify The Forms add-on code to update the spreadsheet
Here is my solution at the moment (still not good enough):
I will store the workflow data (configs, responses) on Firebase Cloud Firestore (a real-time document database, it's like the combination of MongoDB and Firebase Realtime Database)
Each time a request is approved/rejected by the recipient, my non-Apps Script
code will update the data on Firestore
My Forms add-on code will listen to the changes on Firestore and will update the spreadsheet accordingly
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)
Any idea how to solve this problem without the once per hour limit
?
The question is: How a
non-Apps Script
code can modify the Form Responses spreadsheet?
(As already mentioned on a comment by TheMaster) use 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
Yes there is, actually, there are. You could:
Related