Accessing user entered data upon submit in google forms
Remember that the event On form submit
(Understanding Events) receives a parameter that has the following structure:
- values
- range
- namedValues
and you can do something like:
function emailFormSubmission(e) {
...
var row = e.range.getRow();
...
}
Try the following code to observe the structure of the parameter e
:
function emailFormSubmission(e) {
...
Logger.log(e);
...
}
UPDATE
First, excuse my confusion, I showed you the structure of a Spreadsheet form submit event
when you really are using a Form submit event
.
Sure enough, a Form submit event
has the following structure:
- response
Returning an object of type FormResponse
.
Therefore, defining the event: On submit form
(Form submit event
), you can do something like the following:
function emailFormSubmission(e) {
var itemResponses = e.response.getItemResponses();
for (var i = 0, len = itemResponses.length; i < len; ++i) {
Logger.log('Response #%s to the question "%s" was "%s"',
(i + 1).toString(),
itemResponses[i].getItem().getTitle(),
itemResponses[i].getResponse());
}
}
However, the confirmation message set according to the data sent as responses of the form, does not seem very clear, you can set the message, but will not display for the active response, if not for the next.