Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a Google Forms to update existing Google Sheets

I'm trying to build a Google Forms that fills out certain cells of an existing Google Sheets with the responses from the Google Forms. I also need some of the answers on the Google Forms to come from the spreadsheet in a drop down style menu.

The existing spreadsheet is currently being used by an organization to have its members log some information on a weekly basis, however, some members continue to fill out the form incorrectly no matter how many times I've corrected them. For this reason I'm trying to make the process more automated.

The way the current spreadsheet is set up is that there are multiple sheets for different divisions of the organization. In each sheet there is a column dedicated to the names in that division, with a different name on each row of that column. There are also columns dedicated to specific weeks, so week 1 information is say put into Column D and E, Week 2 information in F and G, etc.

EX:

# | Name | Percent |... Week 1 .... |... Week 2 .... | ....

1 |.. Bob..| 0%..... ..| Info 1| Info 2 | Info 1| Info2..|

2 | ..Joe..| 99%......| Info1..................................

I'd like to be able to:

  1. Make the first question of the form a drop down menu selecting the division, which would then make the rest of the questions' information based off the sheet corresponding to that division.
  2. Second question a drop down menu to select the name. The names would be based off the names listed in the already existing name column of the spreadsheet.
  3. A drop down menu to select the specific week they are submitting information for.
  4. A fill in box question that they fill in with "Info 1".
  5. A fill in box question that they fill in with "Info 2".

When submitted the form would find the correct sheet based off (1), then find the correct row based off (2), then find the correct column based off (3), then copy (4) and (5) into the corresponding cells.

Is it possible to do this? Or would I need to create a separate form for each division?

I don't have any familiarity with Google scripting, although I am experienced with C++ and have a basic working knowledge of scripting in Python.

like image 859
Pseduosance Avatar asked Nov 27 '14 05:11

Pseduosance


1 Answers

This will be difficult to implement (but not impossible) with stock Google Forms. You can't use Google Apps Script to manipulate the display of a form in response to user actions like you can with Javascript on a form you've coded from scratch.

Google Apps Script can generate and manipulate a form in the same way you can in the Form Editor, and it can be triggered when the Form is submitted to take action with the response, but it can not interact with the user directly.

To achieve what you want you have a few options.

You could set up a multi-page Google Form with logic branches to get the forms behaviour you want, then use an Apps Script triggered onFormSubmit() to take care of moving data to the appropriate locations.

Or you can skip using stock Google Forms altogether and instead present the form using a Google Apps Script published as a web-app, which gives you full control over the form (HTML, CSS & Javascript) displayed to the user, but you do not get to leverage any of the Google Form features. You could render the form with doGet() and process the submission with doPost().

A third approach would be a hybrid of the two, set up several individual Google Forms, and use an Apps Script published as a Web App to display the first drop down and direct the user to the appropriate form. You could then have scripts triggered onFormSubmit() of each of the Google Forms to handle moving your data around.

See the following:

https://developers.google.com/apps-script/guides/triggers/events#google_forms_events

https://developers.google.com/apps-script/guides/web#deploying_a_script_as_a_web_app https://developers.google.com/apps-script/guides/html/

like image 85
Cameron Roberts Avatar answered Sep 29 '22 05:09

Cameron Roberts