When using Google forms, how do I get the persons name so I can use it in the confirmation email the user receives after submitting the form

When using Google forms, how do I get the persons name so I can use it in the confirmation email the user receives after submitting the form

Look at the Form submit event object

https://developers.google.com/apps-script/guides/triggers/events

Namely, namedValues, which returns an object like this:

{
  First Name: [Jane],
  Timestamp: [6/7/2015 20:54:13],
  Last Name: [Doe]
}

Note that all the values get returned in an array, even if its just one value.
To get the information from this object, you can do the following:

let values = e.namedValues
let name = values.Firstname[0] // assigning first item (only item) of Firstname array to name
let email = values.email[0] // assigning first item (only item) of email array to email

These properties Firstname and email may be different depending on how you named them in your form.

It seems you were trying to call the properties as if they were functions – values.Firstname() – which will not work, unless you can find that function defined in the documentation. Or maybe these are functions that are defined elsewhere in your script.

References

When using Google forms, how do I get the persons name so I can use it in the confirmation email the user receives after submitting the form

Leave a Reply

Your email address will not be published.