我有一些问题,关于这个脚本发送电子邮件后,提交的谷歌形式。
所以,当我运行我的代码时,我收到这个错误信息。ReferenceError: getValues is not defined at onFormSubmit (参考错误:getValues未在onFormSubmit处定义)
下面你可以找到脚本
function onFormSubmit(e) {
Logger.log("[METHOD] onFormSubmit");
sendEmail(e.range);
}
function sendEmail(range) {
Logger.log("[METHOD] sendEmail");
// FETCH SPREADSHEET //
var values = range.getValues();
var row = values[0];
// EXTRACT VALUES //
var DateRequest = values[0]
var TypeRequest = values[1]
var StartDate = values[2]
var EndDate = values[3]
var Observation = values[4]
var TLemail = values[5]
// CLEAN VARIABLES //
if (Observation.length == 0) Explain = "None";
// PREPARE EMAIL //
var emailRecipients = +TLemail+"@google.com";
var emailSubject = TypeRequest;
var emailBody = "<h3>Vacation Request:</h3><hr /> \
<p> \
<strong>Type or request:</strong><br /> \
"+TypeRequest+" \
</p><p> \
<strong>Date of Request:</strong><br /> \
"+DateRequest+" \
</p><p> \
<strong>Start Date:</strong><br /> \
"+StartDate+" \
</p><p> \
<strong>End Data:</strong><br /> \
"+EndDate+" \
</p><p> \
<strong>Aditional comment:</strong><br /> \
"+Observation+" \
</p><p> \
</p>";
// SEND EMAIL //
MailApp.sendEmail({
to: emailRecipients,
subject: emailSubject,
htmlBody: emailBody
});
}
先谢谢你
range
你的代码里没有onFormSubmit
提供一种选择是使用事件对象 range
:
function onFormSubmit(e) {
var values = e.range.getValues();
这将相当于
function onFormSubmit(event) {
var values = event.range.getValues();
或
function onFormSubmit(hello) {
var values = hello.range.getValues();
e.values
所以。
function onFormSubmit(e) {
var values = e.values;
var DateRequest = values[0];
var TypeRequest = values[1];
...
替换为:
var values = range.getValues();
改为
var values = e.range.getValues();