0

I am just trying to run a simple addanswer code in Google Sheets, but the trigger execution log keep showing:

1

vimuth
  • 5,064
  • 33
  • 79
  • 116
  • If you call it like `addAnswer()` then `e` is undefined. Also, wherer do you have `getValue` before running the function? – qrsngky Mar 15 '23 at 07:33
  • I thought that in your situation, these threads of https://stackoverflow.com/q/16089041 and https://stackoverflow.com/q/74109026 might be useful for understanding your current error. – Tanaike Mar 15 '23 at 07:38

1 Answers1

0

There's several issues here, but in regards to getValue:

I'm assuming this is a function set to trigger onFormSubmit and utilizing the e event object, in which case I recommend you look at the 3rd bullet point above on what is and is not possible to retrieve.

If you would rather use the FormResponse class attached in the 2nd bullet point, you can access the most recent form submission by the following function set to trigger onFormSubmit:

function getLatestFormResponse() {

  const Form = FormApp.openById(`YOUR_FORM_ID`)

  const responses = Form.getResponses()
  const latestResponse = responses[responses.length - 1]

  // `latestResponse` is latest FormResponse.

}
NEWAZA
  • 1,536
  • 2
  • 4
  • 19