简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM