In this article, you will learn how to use Google Forms to allow users to update (edit) your Awesome Table app’s content. Examples using this setup include, but are not limited to:
- A school project where your students update your class’ digital library.
- A digital kiosk for your staff where they can update your movie database.
- A job posting board for your recruitment team.
How does it work?
For this setup to work:
a) Share the relevant app to your targeted audience.
b) Instruct your users to click the edit button to modify the content of a particular record.
c) A new tab will launch the relevant row (record) in Google Forms allowing your users to revise the content as needed.
d) Once the update is submitted, your Awesome Table app will reflect the changes made.
Live example
Prerequisites
The following must be present for the entire procedure to work:
- Gmail or Google Workspace account
- Google Forms (with responses)
- Google Sheets containing form responses (that’s actively linked to Google Forms)
Setting up the workflow
The entire procedure involves several parts (Google Apps) with interdependencies. It is complex but easy to follow and implement. The entire procedure can be a bit involved. But once everything’s configured, existing rows of data and newly submitted form entries will automatically have form-edit link buttons that are accessible from your app.
1. Google Forms (with responses)
First, we need to activate a setting in Google Forms that is crucial in the workflow’s functionality.
a) Open the relevant Google Forms then click the gear icon.
b) Tick the box for Edit after submit.
c) Click Save.
2. Google Sheets
Set up the script
var formURL = 'https://docs.google.com/forms/d/yourId/viewform'; var sheetName = 'Form Responses 1'; var columnIndex = 8; function getEditResponseUrls() { var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); var data = sheet.getDataRange().getValues(); var form = FormApp.openByUrl(formURL); for(var i = 2; i < data.length; i++) { if (data[i][0] != '') { var timestamp = data[i][0]; var formSubmitted = form.getResponses(timestamp); if (formSubmitted.length < 1) continue; var editResponseUrl = formSubmitted[0].getEditResponseUrl(); sheet.getRange(i+1, columnIndex).setValue(editResponseUrl); } } }
Run the script
A warning message will be displayed by Google when you run the function for the first time saying that This app isn’t verified. But since we created the script ourselves, you can be assured that this is risk-free.
Click Advanced then Go to <your script name> (unsafe) link to run the script.
Then click Allow.
After which, the script will start generating the appropriate links for each row of data.
Automatically generated links in the data source (via our function).
Configure the Edit button in Google Sheets
Now that we have the form-links, we’re going to create an edit-button using our buttonType keyword.
Create a new column for the edit links (the header’s labeled as Update in this example). We’ll be using the buttonType keyword to enhance the presentation of the edit links. Read more on how to use buttonType.
3. Trigger via Google Workspace Developer Hub
Lastly, we’ll help you create a trigger that will automatically generate an edit-form link each time a new form-entry is submitted by your users.
Assuming that the Apps Script window is still open, select Edit > Current project's triggers.
Otherwise, go to your Form Response data source in Google Sheets and click Extensions > Apps Script. Then follow the step above.
A new tab will open for the Google Workspace Developer Hub. Click the Add Trigger button at the bottom-left corner.
A modal window will appear allowing you to configure the setting for your trigger. Set the settings as shown below:
Settings | Option |
---|---|
a) Choose which function to run |
getEditResponseUrls |
b) Chose which deployment should run |
Head |
c) Select event source |
From spreadsheet |
d) Select event type |
On form submit |
Then click Save (e).
A summary of the new trigger will be shown to you immediately. You’ll notice that there’s a Last run timestamp since we just sent a new submission to test the trigger.
And here’s the new (test) submission with the automatically generated form-edit link. This means that the trigger worked!
- Google Forms and Google Sheets to allow your users to update (edit) your Awesome Table app’s content and
- Automatically generate a button-link each time a new form entry is submitted.