that's my first time here so I am sorry if I will not follow StackOverflow guidelines to the line.
These days I had to create a pipeline for data collected by a Google Survey to a Google Sheet. The issue is that I am not able to debug in any way the function I wrote which should be triggered on-event formSubmit. The function is the following:
function notifyTeam(event) { // should triggered on formSubmit event
var db = getDB() // custom function to connect to datasheet -> works fine
var dt = new Date()
var email = event.responses.getItemResponses()[0] // -> returns error due to event is undefined
var sap_code = event.responses.getItemResponses()[0] // -> returns error due to event is undefined
I would like to know why on Earth the event parameter is undefined while I exactly followed Google Documentation.
Thanks so much for your help in advance.
The fields in an event differ depending on whether the "on form submit" trigger is associated with a form or a spreadsheet. If your script is bound to a spreadsheet, you need to use
event.namedValues
instead ofevent.responses
.See Event Objects documentation.