2
votes

I am trying to collect response details from a google form using a script bound to the form, using the onFormSubmit() trigger.

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.

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 :( Has anyone faced this issue? Please help!!

1
Has this been during a short time period? I wonder if a trouble ticket should be put in.Spencer Easton
Unfortunately, I don't feel that I can ever rely on the response object. I get the response ID from the object and that's all. Then get the response from the Form. var ID = e.response.getId(); Then get the active Form, and get the response. You should make a complaint on the issue tracker: Link to Apps Script Issues ListAlan Wells

1 Answers

2
votes

Unfortunately I spent quite a lot of time trying to use Google Apps and have come to the conclusion that it is not a reliable platform. This became especially apparent when using timed triggers, which would fail for no reason several times a day - even when not in use. Sometimes this would log and sometimes not.

I can't offer any help, beyond my eventual solution which was to write everything from scratch in HTML, PHP and Python.