Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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 :(

When I was successfully receiving responses, e had a response key as well.

like image 787
Flame of udun Avatar asked Sep 02 '16 18:09

Flame of udun


People also ask

Why can't I see my Google Form responses?

If You Don't See Form Data Open the form, and then follow the instructions for choosing where to save form responses, selecting the spreadsheet where you'd like to see the responses as the destination, or unlink the form from the spreadsheet to keep the responses in the form, only.

How do I get my responses after submitting a Google Form?

Open a form in Google Forms. At the top of the form, click Responses. Click Get email notifications for new responses.

Do all the responses submit when I submit Google Forms?

Google Forms counts a single form submission as one response. Data from all responses is available immediately after each form submission in the Responses tab.

How do I fix Google Forms not submitting?

I can't submit my Google forms. Why? This happens for several reasons but the most common one is the respondent hasn't filled out all the required fields in the form. If the problem persists, try clearing your cache and reloading the form.


2 Answers

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.

like image 79
John Siu Avatar answered Oct 22 '22 23:10

John Siu


You may have to go back into your active triggers, delete the trigger, re-add it, and it will prompt you for new access information.

like image 36
Colin Jameson Avatar answered Oct 22 '22 23:10

Colin Jameson