'Appscript - get form response in array [duplicate]
I am new in appscript and now i want to store the responses filled in the form in a array and then use this array to store the data in a custom format in a spreadsheet, the problem is that i am trying to store and send the response with a manual trigger onFormSubmit, when i submit the form, some information about the sheet i want to modify is logged in console but the data itself can't be retrieved, below is what i am trying, first approach is to get the active form and the second is to catch the response from event, but neither of them are working. how can i accomplish it?
var SPREADSHEET_ID = "SPREADSHEET ID",
SHEET_NAME = "SHEET NAME";
function onFormSubmit(e) {
var sheet = SpreadsheetApp.openById(SPREADSHEET_ID),
form = FormApp.getActiveForm();
var formResponse = e.response;
Solution 1:[1]
I'm writing this answer as a community wiki, since the solution was provided by OP in the comments section. This, to provide a proper response to this question.
Since OP does not (as mentioned in the comments) have a Spreadsheet linked to the form in use, does not want to store responses in any Spreadsheet but only catch the responses as they are submitted, solution was provided in the comments by OP where basically:
An onFormSubmit
trigger is set up with:
getResponse()
as a function in the form of:
function getResponse(e) { var response = e.values; }
From Spreadsheet
as the Event SourceOn form submit
as the Event Type
In this scenario, the event objects are used to get the values submitted in the form response. Resulting in the desired outcome below:
[25/07/2019 10:02:36, Option 1, Answer 2, Option 3]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |