I am trying to create a script that will use a submitted Google Form to create an agenda for a meeting. I used the script "Employee of the Week Award" as a starter but my total inexperience with coding has me stumped.
I have created a googde doc agenda template with key place holders matching the data I'm asking for in the google form (thus the headers of the columns in my google spreadsheet). The goal is when someone submits a form describing the agenda items for their meeting, this script grabs that data and uses the google doc agenda template to create an agenda for their meeting.
Here's the script I've edited:
// Global variables
var docTemplate = "1-4ELCpEGvrtnprnBYoLapwASK6TYmt3YpY0BkBKICrM";
var docName = "Agenda";
function onFormSubmit(e) { // add an onsubmit trigger
// Meeting name and date values come from the spreadsheet form
var meeting_name = e.values[1];
var date = e.values[2];
// Get document template, copy it as a new temp doc, and save the Doc’s id
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(docName+' for '+Meeting_Name)
.getId();
// Open the temporary document
var copyDoc = DocumentApp.openById(copyId);
// Get the document’s body section
var copyBody = copyDoc.getActiveSection();
// Replace place holder keys,
copyBody.replaceText('keyMeeting_Name', Meeting_Name);
copyBody.replaceText('keyDate', Date);
var Agenda_Item_1 = e.values[3]
var Item_1_Time = e.values[4]
var Agenda_Item_2 = e.values[5]
var Item_2_Time = e.values[6]
var Agenda_Item_3 = e.values[7]
var Item_3_Time = e.values[8]
copyBody.replaceText('keyAgenda_Item_1', Agenda_Item_1);
copyBody.replaceText('keyItem_1_Time', Item_1_Time);
copyBody.replaceText('keyAgenda_Item_2', Agenda_Item_2);
copyBody.replaceText('keyItem_2_Time', Item_2_Time);
copyBody.replaceText('keyAgenda_Item_3', Agenda_Item_3);
copyBody.replaceText('keyItem_3_Time', Item_3_Time);
// Save and close the temporary document
copyDoc.saveAndClose();
}
When I run it, I get TypeError: Cannot read property "values" from undefined (line 7)
. I'm assuming that error would be true for all the subsequent e.values
lines.