首页 > 解决方案 > Debuggin function wrapped by triggers - Google Scripts

问题描述

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.

标签: debugginggoogle-apps-scriptgoogle-sheetsgoogle-surveys

解决方案


事件中的字段会有所不同,具体取决于“提交表单”触发器是否与表单或电子表格相关联。如果您的脚本绑定到电子表格,则需要使用event.namedValues而不是event.responses.

请参阅事件对象文档。


推荐阅读