0

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.

vitooh
  • 4,132
  • 1
  • 5
  • 16
J.DG
  • 1
  • Question seems to be how this function is called. It seems to be invoked with `undefined` argument. Can you add link to the documentation you've followed? – vitooh Apr 21 '21 at 09:13

1 Answers1

1

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 of event.responses.

See Event Objects documentation.

doubleunary
  • 13,842
  • 3
  • 18
  • 51