How to autofill respondent's email addresses in Google Forms?
Asked Answered
H

2

7

So, I would like that when I send an email via a Google Form (now it is possible to embed the whole form automatically in the message - I usually do this) the email of the recipient would already be filled within the appropriate field. It should still be possible for the respondent(s) to change it in case They wish to use a different address for receiving a comfirmation email.

In the case of multiple recipients, each recipient should obviously have Their own email address autofilled.

Visually (being a freshling, I haven't got the reputation to directly embed the image):

The highlighted part in the image should automatically be filled, based on the email address the form was sent to.

I'm sure that this should be done trough scripts, but Im not adept enough with scripting yet. I found this, but that doesn't quite do, mostly because I don't wat to use pre-defined contact lists.

Did I manage to be clear enough? :) This is my first question, I hope I managed to put it on a par with expectations.

Hautrhin answered 3/10, 2016 at 12:52 Comment(5)
not a valid question for s.o. which is for those wanting to learn how to code it, not for asking for the code given a specification. to make it valid, show us your attempts so far in apps script and what is failing.Shir
Truth be told, I haven't created anything closely resembling what I need. Directions on where to look are also welcome. I was and am still searching the web, but all I get are codes similar to the one linked above, codes that use pre-existing e-mail lists. If my question in this manner is completely innapropriate for StackOverflow, I will delete it.Hautrhin
Its too broad because there is no code or algorithm that you have tried yet. Keep in mind that its not possible to do what you ask directly on the responses sheet. You will need to keep a separate sheet where you consolidate the info, and use something like onFormSubmit to detect new entries. This is I think also too broad for a proper answer.Shir
I see, thank You. I will delete this question, and come back once I have more to show. ;)Hautrhin
@Hautrhin for the record, I'm glad that you didn't delete this.Bathypelagic
F
3

First of all open script editor of the form and paste the following code:

function myFunction() {
      var form = FormApp.openById(YOUR_FORM_ID);
      var items = form.getItems();
      var url = form.createResponse().withItemResponse(items[1].asTextItem().createResponse(Session.getActiveUser().getEmail())).toPrefilledUrl());  //items[1] is the input question for email ID

      Logger.log(url);
    }

Now, run this code and check your logs(Ctrl+Enter) and you will be able to see a URL. Paste that in your browser and you will get prefilled and link. Hope it helps.

Filmore answered 4/10, 2016 at 10:33 Comment(0)
K
0

3 dots on the form top right and then get PRE-FILLED link

Kaila answered 16/9, 2023 at 13:8 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Witenagemot

© 2022 - 2024 — McMap. All rights reserved.