I am just trying to run a simple addanswer code in Google Sheets, but the trigger execution log keep showing:
Asked
Active
Viewed 309 times
0
-
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 Answers
0
There's several issues here, but in regards to getValue
:
.getValue
generally requires parenthesis as it is a function/method. (.getValue()
)- There is no
getValue()
method for FormResponse: https://developers.google.com/apps-script/reference/forms/form-response - There is no
getValue
property for onFormSubmit installed trigger events: https://developers.google.com/apps-script/guides/triggers/events#form-submit
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