Prefill a Google Form using data from the last response

扶醉桌前 提交于 2019-12-06 14:46:06

问题


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


回答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



来源:https://stackoverflow.com/questions/26147287/prefill-a-google-form-using-data-from-the-last-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!