Default value in Form text input

664 views
Skip to first unread message

Pete Banks

unread,
May 29, 2023, 12:10:02 PM5/29/23
to Google Apps Script Community
I have searched through the gs documentation and this site and failed to find any way to pre-fill a value in a TextItem on a Form.

It would be used to allow a largish number of registrants (people) to make each multiple entries to a competition, using a registration number (the pre-filled value) instead of having to enter their name on each entry form. Registration would be by a Form which would automatically email the registrant with the registration number, competition information, and a link to the pre-filled entry Form.

Using the Card service it is possible to place a default value in a widget, but I can't find how to do this for a Form. The various pre-fill form services I have found all are for 'mail merge' type set-ups sending a batch emails, not for the one-off situation I am looking for.

Many thanks for any help.
Pete

Jon Couch

unread,
May 29, 2023, 1:20:05 PM5/29/23
to google-apps-sc...@googlegroups.com
Pete, if I understand correctly what you're trying to do, this is the way I've done this in the past. 
  1. Click on the 3 dots in the top right corner of the form edit screen
  2. Choose Get pre-filled link 
    image.png
  3. A live form will open
  4. In the field that will contain the registration number, enter easily recognizable text, e.g. 998877
  5. At the bottom of the form click Get Link, then Copy Link when that option shows up.
  6. Paste the link into a text editor where you can see the URL. It will look something like this: https://docs.google.com/forms/d/e/ScDgl4MdgiGOlJq9BwylMMOz-NnMrXE_YIHS9mbGNPoJQ8jVA/viewform?usp=pp_url&entry.579426108=998877
  7. The number immediately after "entry" is your "question number" and the value after the = sign is where you would put your registration number.
  8. You would build the URL string you send to the user by concatenating  the bulk of the URL to the equal sign after the question number and the registration number you want to assign: "https://docs.google.com/forms/d/e/1FAIpQLScDgl4MdgiGOlJq9BwylMMOz-NnMrXE_YIHS9mbGNPoJQ8jVA/viewform?usp=pp_url&entry.579426108=" + regnum
There are other, more elegant ways to get the question number but since you only need to get it one time, this is pretty simple. BTW: When using prefilled links I often add a warning in the question description telling the user not to make a change to that entry.

I hope that helps.

Jon


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/9bb8c2a4-a883-4f2b-9747-dfd6fc0d9dden%40googlegroups.com.

Pete Banks

unread,
May 29, 2023, 11:51:55 PM5/29/23
to Google Apps Script Community
Thanks Jon. Just what I was looking for - building the URL is easy, so easy I of course did not think of it!

I had thought of setting the TextValidation to the regnum as a way of preventing the entry being altered, but that is probably a step too far.

Reply all
Reply to author
Forward
0 new messages