我创建了一个Google表单,该表单完成后会向管理层发送电子邮件以进行授权。授权表单后,电子表格会更新并显示管理人员的答复和日期。我还创建了一个跟踪表,以防表单被批准但后来被拒绝,反之亦然。想法是,每次进行更改时都会复制该行。我正在使用的代码是:
function doGet(e) {
// Update Spreadsheet
var answer = e.parameter.approval;
var workingRow = e.parameter.r;
var d = new Date()
responses.getRange(workingRow, 12).setValue(answer);
responses.getRange(workingRow, 13).setValue(d);
var tracker = responses.getRange("A" + (workingRow) + ":Z" + (workingRow));
copytoTracker(tracker)
// Email
var ctlEmail = e.parameter.reply;
var sltName = e.parameter.sltName;
// Send Approval Email
GmailApp.sendEmail(ctlEmail, "Student Timetable Change Request", "Thank you for your timetable request. Please note, " + sltName + " has responded to your request and it has been " + answer);
var app = HtmlService.createHtmlOutput(sltName + " thank you for your response.")
//var emailSubject = getDefaultEmailBody();
return app
}
function copytoTracker(tracker) {
var source_sheet = ss.getSheetByName("Form Responses 1");
var target_sheet = ss.getSheetByName("Tracker");
var source_range = tracker;
var last_row = target_sheet.getLastRow();
target_sheet.insertRowAfter(last_row);
var target_range = target_sheet.getRange("A" + (last_row + 1) + ":Z" + (last_row + 1));
source_range.copyTo(target_range);
}
我要去哪里错了?响应和日期在正确的单元格中,但是,每次不会仅在第一行上复制正确的行。
第一行尚未被授权/拒绝,这是导致错误的原因吗?
谢谢
法齐拉