我有一个工作表,可在订单项的列H被标记为“完成”后发送电子邮件。最近,代码已停止工作,并且出现此错误:
找不到脚本功能:onEdit
执行记录
[18-09-10 11:59:29:910 PDT] SpreadsheetApp.getActiveRange() [0 seconds]
[18-09-10 11:59:29:910 PDT] Range.getRow() [0 seconds]
[18-09-10 11:59:29:910 PDT] Range.getLastRow() [0 seconds]
[18-09-10 11:59:29:911 PDT] Range.getColumn() [0 seconds]
[18-09-10 11:59:29:911 PDT] Range.getLastColumn() [0 seconds]
[18-09-10 11:59:29:911 PDT] Session.getActiveUser() [0 seconds]
[18-09-10 11:59:29:911 PDT] User.getEmail() [0 seconds]
[18-09-10 11:59:29:912 PDT] SpreadsheetApp.getActiveSpreadsheet() [0 seconds]
[18-09-10 11:59:29:920 PDT] Starting execution
[18-09-10 11:59:29:927 PDT] Execution failed: Script function not found: onEdit [0 seconds total runtime]
代码如下:
function installTriggers() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
deleteTriggers();
ScriptApp.newTrigger('onSheetEdit').forSpreadsheet(ss).onEdit().create();
ScriptApp.newTrigger('SendConfirmationMail').forSpreadsheet(ss).onFormSubmit().create();
}
function onSheetEdit(e) {
Logger.log(Session.getEffectiveUser().getEmail());
//if the most recently edited cell doesn't contain a "Completed" and it's not the column of your "status" then we're not concerned with it.
if (e.value == "Completed" && e.range.getColumn() == 9 )
{
SendCompletedMail(e);
}
}
function SendCompletedMail(e)
{
var ss, cc, sendername, subject, message, value, textbody, sender;
ss = SpreadsheetApp.getActiveSheet();
var currentrow = e.range.getRow();
cc = "email@abc.com";
sendername = "Request handler";
subject = "Request has been Completed';
message = "Your request has been completed.<br>Thank you for submitting your request.";
//This is the submitter's email address from the sheet - make sure this column matches the email address column of the submitter
sender = ss.getRange(currentrow, 7).getValue().toString();
Logger.log(sender)
textbody = message.replace("<br>", "\n");
GmailApp.sendEmail(sender, subject, textbody, {
cc: cc,
name: sendername,
htmlBody: message
});
}
是什么原因导致找不到onEdit()
函数?