0

I have an app that sends emails after a form is submitted and I would like to use the form response data from a couple of questions in the email subject.

currently the email subject is pulling from this

const subject = "Text -" + this.title

I was thinking, but am not sure how to reference a specific form question using getResponse() or if this is the proper solution const subject = "Text -" + this.title + getResponse()

Rubén
  • 34,714
  • 9
  • 70
  • 166
tk99
  • 5
  • 1
  • 2
  • We don't know what library do you use and how does your code works. – Konrad Apr 19 '22 at 21:30
  • https://github.com/ashtonfei/google-apps-script-projects/blob/GAS-070/app.js#L179 This is the project I'm trying to edit for my needs, line 179 is what I want to change to include answer from form question, so its in title of email sent, but do not know how – tk99 Apr 19 '22 at 21:37
  • Are you using the spreadsheet onFormSubmit or the form onFormSubmit? If it's the spreadsheet then look at the event object values or namedValues. Here's a [link](https://developers.google.com/apps-script/guides/triggers/events#form-submit) – Cooper Apr 19 '22 at 21:45
  • From form - On form submit is the trigger – tk99 Apr 19 '22 at 21:52

1 Answers1

1

It's very likely that the source that lead you to getResponse() was refering to FormApp.ItemResponse.getResponse.

In order to be able to used this method, first your code should grab the FormApp.FormResponse which is usally got from for form submit event object from a Form trigger, but the project that you are referreing is using a spreadsheet trigger which might make things easier as it already includes two properties with the response values:

  • values
  • namedValues

For details please checkout https://developers.google.com/apps-script/guides/triggers/events#form-submit

Related

Rubén
  • 34,714
  • 9
  • 70
  • 166