The onSubmit trigger in Google Forms is causing the e.namedValues variable to be

My apps script has a form submit trigger configured as shown below: https://i.sstatic.net/FNgCD.png

The function onSubmit looks like this:

function onSubmit(e) {
  console.log("Form submitted", JSON.stringify(e.namedValues));
  console.log("Form submitted", JSON.stringify(e));

}

However, when I submit the form, the trigger fires and the function executes. But strangely, e.namedValues is undefined.

https://i.sstatic.net/BGMdS.png

What could be causing this issue? (Even linking a spreadsheet to the form did not change the outcome).

Answer №2

Automatically Retrieve Responses from Google Forms

This code snippet enables you to automatically fetch responses submitted to your Google Form and view them in the Executions tab of Google Apps Script.

It's worth noting that this method bears some resemblance to @Cooper's technique mentioned in their recent comment.

const onSubmit = (e) => {
  var response = e.response;
  var itemResponses = response.getItemResponses();
  var formResponse = {};

  itemResponses.forEach(itemResponses => {
    var itemTitle = itemResponses.getItem().getTitle();
    var value = itemResponses.getResponse();
    formResponse[itemTitle] = value;
  });
  console.log("Response received: " + JSON.stringify(formResponse));
}

The example form appears as shown below:

https://i.sstatic.net/R0Zrv.png

OUTPUT

https://i.sstatic.net/B1bys.png

REFERENCE

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the equivalent in AngularJS to triggering a form submission event like jQuery's $("#formID").submit()?

After the completion of a form with various fields, I require the user to either register or login in a modal window before submitting the form. The process involves opening a modal window with a login form when a user attempts to submit the main form. On ...

Having trouble getting my local website to load the CSS stylesheet through Express and Node.js in my browser

https://i.stack.imgur.com/qpsQI.png https://i.stack.imgur.com/l3wAJ.png Here is the app.js screenshot: https://i.stack.imgur.com/l3wAJ.png I have experimented with different combinations of href and express.static(""); addresses. However, I am ...

Tips for organizing ng-repeat information according to a condition of true or false

Apologies if this question has already been addressed, but I have not been able to find a solution. I am attempting to organize an ng-repeat based on the selection of radio buttons, but I am struggling with hiding and showing items within the ng-repeat. ...

Encountering a difficulty in sending data to the server through ajax with Cordova

I am currently working on a Phonegap Cordova project and I'm trying to send data to the server using AJAX but I'm encountering an error. Here is an example of my code: $(document).ready(function() { $('#frm').submit(function() ...

When the JavaScript alert appears, play audio and then pause it when the alert is closed

I am attempting to have an audio play when a JavaScript alert is triggered and stop playing the audio when the user dismisses the alert. However, I am encountering an issue where the audio does not stop when the user closes the alert. Additionally, the a ...

Creating a Javascript map that holds an array of strings as values, mirroring the functionality found in Java

Seeking guidance on implementing HashMap functionality in JavaScript. Discovered the map() global object introduced in ES6 for this purpose. However, encountering issues when attempting to set a value as an array. Any help would be appreciated. Map-JavaS ...

Unusual manifestation of the Array

I defined a list array as: list: string[] = []; and added elements to it like this: let infoFile: string = fileReader.result; this.list.push(infoFile); After checking the console log, I noticed something strange [] 0 : "data:image/jpeg;base ...

Linking Redux to the highest level of my application is not functioning as expected

I have been attempting to troubleshoot this code for quite some time now, but I am struggling to identify the issue at hand. My main goal is to establish a connection between my top-level application and the redux store. However, every time I try, the stor ...

Import and Showcase Collada Models with Textures using Three.js and file inputs

Currently, I am faced with a challenge involving loading a Collada file along with textures from file inputs. Specifically, I have set up 2 inputs, one for the geometry (.dae) file, and another for textures (.png/.jpg). When these file inputs change, two s ...

JavaScript Promise Synchronization

I have a JavaScript function that returns an object using promises. The first time the function is called, it fetches the object, but for subsequent calls, it returns a cached instance. To simulate the fetching process, I've added a delay. var Promis ...

The battle between AngularJS, Factory, $scope, and promises intensifies

Currently facing a challenge with the code snippet below: app.factory('sfAttachment', ['$http', '$q', '$window', '$rootScope', function($http, $q, $window, $rootScope) { var attachment = {}; //Functio ...

Node.js implementation to transfer MongoDB to CSV, with the unfortunate loss of certain columns

I have a script that exports a MongoDB table to CSV but I seem to be missing some columns. It appears that the column with many null values (where the first 100 rows are all null) is not being included in the exported CSV file. const mongodb = require(" ...

Automatically reveal or conceal an element based on the entry of a value in an input field, without relying on the keyup() or click events

I have a form field with a Bootstrap Datepicker that populates an <input> tag with a selected date. <div class="wrapper"> <div class="form-group"> <label>Select Date</label> <div class="input-group"> ...

How can I modify this section of the code in Google Script to retrieve all columns?

My question is, how can I modify this code to fetch all columns from the array instead of just [0,1,2,3] Here is the line of code in question: const new_table = [0,1,2,3].map(x => make_row_from_col(this_table, x)).join('\n'); Using obje ...

Adapt appearance according to the length of the text

Currently, I have an array that stores multiple strings based on displayed charts. My objective is to find the longest string within this array. So far, this task has been executed without any issues. The code snippet for this process is as follows: var ...

How can I force an element to overflow without being affected by its parent's overflow style in CSS/HTML/JS, even if the parent is

I've come across many inquiries on this subject, but the proposed solutions never seem to work when dealing with ancestors that have absolute positioning. Take this example: <div id='page'> <div id='container' style= ...

We were unable to locate the module: Unable to locate './components/counter' in 'C:/...democounter-appsrc'

I'm completely new to React and currently following tutorials by MOSH on YouTube. However, I've encountered an error that I can't seem to resolve even after searching for similar questions. index.js import React from 'react'; imp ...

Automatically calculate the total using jQuery in a Laravel project

Hey there! I'm working on a form where users can check a checkbox and enter a value, with the total being automatically calculated. I'm using jQuery and Laravel 7 for this project, but I am running into an issue where the total is not appearing. ...

Using the parseInt method, you can easily combine integers and strings to perform addition and string concatenation simultaneously

Here is the code snippet I am working with: if (ev.data.type === "height") { if (ev.data.form === src) { setHeight(ev.data.message + "px"); } } Currently, the default height being added is 1900px. I would like to increase it by ...

Tips for avoiding the influence of the parent div's opacity on child divs within a Primeng Carousel

I'm struggling to find a solution to stop the "opacity" effect of the parent container from affecting the child containers. In my code, I want the opacity not to impact the buttons within the elements. I have tried using "radial-gradient" for multipl ...