简体   繁体   English

在表单提交中收到的Google表单事件没有回复

[英]Google forms event received on Form submit has no responses

I am trying to collect response details from a google form using a script bound to the form, using the onFormSubmit() trigger. 我正在尝试使用绑定到表单的脚本从谷歌表单收集响应详细信息,使用onFormSubmit()触发器。

Most times the details are received without error, but once in a while I get an error. 大多数情况下收到的细节没有错误,但偶尔会出现错误。 The trigger is received but no data is passed to the script. 收到触发器但没有数据传递给脚本。 The response is received by the google form console but not forwarded to the script. 响应由Google表单控制台接收,但不会转发到脚本。

Code for receiving data: 接收数据的代码:

function onFormSubmit(e)
{

  Logger.log("A response has been received!");
  Logger.log(e);
  var resp = e.response.getItemResponses(); //capturing trigger event output
  var form = e.source;
......

Execution transcript in case of error: 出现错误时的执行记录:

[16-09-27 07:29:15:073 PDT] Starting execution
[16-09-27 07:29:15:096 PDT] Logger.log([A response has been received!, []]) [0 seconds]
[16-09-27 07:29:15:097 PDT] Logger.log([{authMode=FULL, triggerUid=xxxxxxx41}, []]) [0 seconds]
[16-09-27 07:29:15:099 PDT] Execution failed: TypeError: Cannot call method "getItemResponses" of undefined. (line 18, file "Code") [0.002 seconds total runtime]

Until now, I have redressed it by duplicating the form and re-setting all the permissions. 到目前为止,我通过复制表单并重新设置所有权限来解决它。 But I would like a solution that doesn't have me doing this again. 但是,我想要一个不再让我这样做的解决方案。 On my 10th duplicate now :( 在我的第10次重复现在:(

When I was successfully receiving responses, e had a response key as well. 当我成功收到回复时, e也有一个回复键。

This is a work around that should prevent your script from breaking: 这是一个可以防止脚本破坏的解决方法:

function onFormSubmit(e)
{
  Logger.log("A response has been received!");
  // Check if e is defined
  if (e) {
    // Any code that use e should be inside this block
    Logger.log(e);
    var resp = e.response.getItemResponses(); //capturing trigger event output
    var form = e.source;
  } else {
    // Log if e is undefined
    Logger.log('e is undefined!');
  }
......

I agree with Rubén that you should contact google support to look into the issue, especially you can see the response in console. 我同意Rubén你应该联系google支持来调查这个问题,特别是你可以在控制台中看到响应。

您可能必须返回到活动触发器,删除触发器,重新添加它,它将提示您输入新的访问信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM