google forms and google apps script communication and interpretation

So I've been working on a script to handle responses from one of my google forms, and for some reason, when the form submits, it doesn't define the namedValues properly and my script cant see the responses and returns
"TypeError: Cannot read properties of undefined (reading 'Minecraft Username:') at handleFormSubmit(Code:16:41)".

The issue at the moment seems to be the username read from response [0]. I'll post the function below, (the part that is dysfunctional. I need to protect privacy so the rest of the code is not shown). did I miss something? It's racking my brain why responses aren't visible to my app script.

function handleFormSubmit(event) {
  console.log('Form submitted'); //logs the submit action to show the trigger is functioning
    console.log(event); // Logs the event object to inspect its structure for debugging
  var playerUsername = event.namedValues["Minecraft Username:"][0]; //should pull from first response
  var serverAddress = event.namedValues['Server'][1]; //should pull from second response
0 2 1,163
2 REPLIES 2

You might have better luck asking over on the Apps Script Community group: https://groups.google.com/g/google-apps-script-community/, which is a very active and helpful group.


@icrew wrote:

You might have better luck asking over on the Apps Script Community group: https://groups.google.com/g/google-apps-script-community/, which is a very active and helpful group.


well, that solves my problem of not being able to find that community. hats off to you @icrew 

Top Solution Authors