1

I am building a Google Form that I am the only one to use. I use the form 2 times a day (more or less) and I would like some of the fields to be prefilled with the value of the last response I gave, because their values are not suppose to change often.

I save my responses in a google spreadsheet so I could get them from there but I am very new to Google Apps Scripts and I haven't seen an event that triggers when someone opens a form to answer it yet. I'm not even sure such an event exists...

And also, I would like to access my form from always the same URL (so no prefill that way) because I saved the URL as a favorite on my smart-phone's desk and don't want to change it every day :)

So, is there a way to prefill a Google Form using data from the last response or at least an event that triggers when answering the Form ?

Thanks in advance

manu
  • 1,059
  • 1
  • 16
  • 33

2 Answers2

1

There is both an On Form Submit and On Open trigger. In the Apps Script code editor, click on the Resources menu. Create an Apps Script that is tied to the form. There is a Tools menu in the Form Editor. Use the Tools menu to open the Apps Script code editor.

So, retrieving the last value from the spreadsheet is doable. I can't find anything that makes me think you can pre-fill a form field. But I hope I'm wrong, and somebody has the answer.

You could have a script that simply writes the last value to the new row if a certain response field is empty. So instead of pre-filling the field, just leave it empty if you want the same value written. Although, if you don't know what that value is, you might not know if that's what you want entered again.

There is a way to deal with that though. You could write the last value in the spreadsheet into the help text of the form item.

Google Documentation - Form Set Help Text

So, you could know what the last value was by looking at the help text.

Or I'm wondering if you could set the choices in a List Item:

Google Documentation - Set Choices

If you want to do more work, and learn HTML, you can do what you want with an HTML app.

Google Documentation - HTML Service

Alan Wells
  • 30,746
  • 15
  • 104
  • 152
  • 1
    I have seen the open event but it occurs only when you edit the form not when someone answers it. Form Submit is also not a good solution because obviously I want the fields to be prefilled before I answer the questionnaire. For the same reason, I cannot put the value of the last line of my spread sheet in the help text unless I open the form edition every time before answering it to trigger the open event. The solution to copy the value of the last line if my spread sheet onEdit if the value is empty seems doable. Hadn't thought of that. But it's still not the best solution... Thanks anyway – manu Oct 02 '14 at 08:33
  • 1
    The stylesheet onEdit solution gives the same results as prefilling the fields on form submit actually... Thanks for the HTML Service advice but I want to do it whith google forms. I allready know HTML, I'm just eager to learn something new :) – manu Oct 02 '14 at 08:47
-1
  1. From form edit page, select menu (3 dots) -> "Get pre-filled link"

  2. fill out your form and copy the link.

  3. bookmark or email the link to yourself for future use.

John Conde
  • 217,595
  • 99
  • 455
  • 496
West
  • 1