我有一个谷歌表格,用户可以输入他们注册的运动项目。他们输入他们的电子邮件、地址、姓名等。然后,我在电子表格中为Total添加了一列,这是一个数组公式,根据他们的答案计算他们欠的总额。用户提交时带有表单的电子表格效果很好。
但是在脚本管理器中,我有一个在 onFormSubmit 上触发的函数(见下文)。当用户填写并提交表单时,会发送“确认”电子邮件,并且所有字段都应为它们应该是的,除了 Total 出现未定义- 这是 arrayformula 列。为什么?我们不能发送这些字段吗?我真的需要电子邮件告诉用户他们欠了多少钱。 如何引用用户刚刚提交的行的 Total 列?
function onFormSubmit(e) {
var timestamp = e.values[0];
var toAddress = e.values[1];
var LastName = e.values[2];
var Street = e.values[3];
var City = e.values[4];
var Zip = e.values[5];
var Phone = e.values[6];
var Student1 = e.values[7];
var GradeS1 = e.values[8];
var BdayS1 = e.values[9];
var GenderS1 = e.values[10];
var SportS1 = e.values[11];
var Student2 = e.values[12];
var GradeS2 = e.values[13];
var BdayS2 = e.values[14];
var GenderS2 = e.values[15];
var SportS2 = e.values[16];
var Student3 = e.values[17];
var GradeS3 = e.values[18];
var BdayS3 = e.values[19];
var GenderS3 = e.values[20];
var SportS3 = e.values[21];
var Student4 = e.values[22];
var GradeS4 = e.values[23];
var BdayS4 = e.values[24];
var GenderS4 = e.values[25];
var SportS4 = e.values[26];
var Total = e.values[30];
var subject = "Registration";
var htmlBody = "The Registration details you entered were as follows:" +
"<br/><br/> Date/Time Submitted: " + timestamp +
"<br/> Family: " + LastName +
"<br/> Address: " + Street + ", " + City + ", " + Zip +
"<br/> Phone: " + Phone +
"<br/> Student 1: " + Student1 + ", " + GradeS1 + ", " + BdayS1 + ", " + GenderS1 + ", " + SportS1 +
"<br/> Student 2: " + Student2 + ", " + GradeS2 + ", " + BdayS2 + ", " + GenderS2 + ", " + SportS2 +
"<br/> Student 3: " + Student3 + ", " + GradeS3 + ", " + BdayS3 + ", " + GenderS3 + ", " + SportS3 +
"<br/> Student 4: " + Student4 + ", " + GradeS4 + ", " + BdayS4 + ", " + GenderS4 + ", " + SportS4 +
"<br/><br/> TOTAL DUE: <b>$" + Total +
"</b><br/><br/>Please send your payment, <b>checks payable to Our Company </B> , to: <font color=\"red\"><b>Person Name</font></b>" +
"<br/><br/>Your registration will not be activated until payment is received. Thank you so much!" +
"<br/><br/>From Our Company";
var optAdvancedArgs = {name: "Our Company", htmlBody: htmlBody};
MailApp.sendEmail(toAddress, subject, "Message Body", optAdvancedArgs);
}
谢谢,如果你能帮忙,请!