Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
365 views
in Technique[技术] by (71.8m points)

google apps script - Using data from sheet for form

I have a google sheet where I've created a form (survey) using scripting. In that sheet, I've assigned x number of users a unique user id (e.g. DR8371 or JH3059) to help keep track of who's taken the survey and what their answers are (this is not meant to be anonymous). However, I can't figure out how to attach the user id from the sheet to the form (the sheet contains the form responses though). The first question on the form asks what the user's ID is, and I don't want the form to submit the responses unless the user ID is correct. Is there a way do this? The user ID's need to stay on the sheet where I currently have them stored.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can prefill an input field in a Google Form with the ID and distribute the resulting pre-filled URL out to the right user. However, the user can always delete or change the value. There are no hidden field types to protect against that either. Also, hiding a input field on a page the user can't navigate to seems to return an empty response for that field instead of keeping the pre-filled value.

You could use a regular expression in the field's advanced validation as a "check" to whether the ID matches a range or the exact number you want. However, we can't currently set or update any validation via scripts ( see and vote for Issue 4216 ) so you would have to keep doing that manually.

If you absolutely want to prevent a pre-filled id from being changed by the user, that may require creating a separate Google Form for each user with advanced validation setup to match just 1 id.

There's also no ability to for a script to "check" whether the ID is right as the user fills out the form. See this post for more on that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...