Tuesday, 17 August 2021

Send data to a Google Form via Apps Script

The following Google Apps Script is designed to submit specific data to a Google Form, by creating a prefilled URL. The reason for this was I needed some way of sending data from a number of individual Google Sheets (that I did not own) to one central location, but crucially it needed to be anonymised.

Sending the data directly to a Google Sheet includes version history both in the file and cell meaning it was not truly anonymous. Whereas sending the data through a Google Form and then on to the Response Sheet did strip away anything identifiable.

The logic behind this code is to create a prefilled URL which contains answers to each of the Forms questions. Use the previous webpage link to learn how to create such a URL first so that you understand each question on a Form has a unique value.

Questions from a Google Form can be answered in advanced via a prefilled URL.
Screenshot of Google Form questions

Instructions

  1. Follow this guidance to learn how to create a prefilled URL. From this you can identify the IDs of each question to use below.
  2. Add the data you want to send to the Google Form in to the Apps Script code.
  3. Enter the URL of the Google Form in to the Apps Script code (this is the URL you would send out when asking people to complete the Form - minus the '/viewform' text at the end).
  4. Piece together the ID of each question and the corresponding data.
  5. Hit 'Run' to submit the information.

 

File Download

Download the Send data to a Google Form via Apps Script here. Please use 'File' > 'Make a copy' for your own version. This is just a Google Apps Script file and does not contain a Google Form.


No comments:

Post a Comment