我正在尝试创建一个脚本,该脚本将使用提交的Google表单来创建会议议程。我使用了剧本“每周雇员奖”作为首发,但我对编码的经验不足让我感到难过。
我创建了一个googde doc议程模板,主要占位符与我在google表单中要求的数据相匹配(因此我谷歌电子表格中列的标题)。目标是当有人提交描述会议议程项目的表单时,此脚本会抓取该数据并使用Google doc议程模板为其会议创建议程。
这是我编辑过的脚本:
// 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();
}
当我运行它时,我得到TypeError: Cannot read property "values" from undefined (line 7)
。我假设所有后续e.values
行都会出现错误。