0
votes

I have a Google Form that has many questions, but I only want to record some of the responses into a separate, condensed spreadsheet. These are the responses I want to record:

First Name
Last Name
Company
Role    

This is my script, which is triggered to execute on form submission:

function copyCondensedResponseData(e) {

   var array_to_paste_in_participant_attendance_sheet = [];
   array_to_paste_in_participant_attendance_sheet.push(e.namedValues["First Name"].toString());
   array_to_paste_in_participant_attendance_sheet.push(e.namedValues["Last Name"].toString());
   array_to_paste_in_participant_attendance_sheet.push(e.namedValues["Role"].toString());
   array_to_paste_in_participant_attendance_sheet.push(e.namedValues["Company"].toString());

   var participant_attendance_sheet = SpreadsheetApp.openById(/* id */).getSheets()[0];

   participant_attendance_sheet.getRange(participant_attendance_sheet.getLastRow()+1,1).getValues()[0] = array_to_paste_in_participate_attendance_sheet;
}

But nothing is pasted into the participate_attendance_sheet. I know that typically you copy data from one sheet into another by calling getRange() and setValues(), but I think that's only if the data I want to copy is of the class Object [ ] [ ]. Any thoughts?

1

1 Answers

0
votes

You still need to use setValues. In this case the input is an 1 by 4 multidimensional array.

var input = [participant_attendance_sheet];
var r = participant_attendance_sheet.getRange(participant_attendance_sheet.getLastRow()+1,1,1,4);
r.setValues(input);