当为changeType == "OTHER"时,我需要能够调用发生更改的行号。下面是一个测试脚本(在更改时通过runNotify触发),它应该通过电子邮件发送给我进行更改的行号,但它只返回"1“作为行号。我遗漏了什么,使它无法返回已更改行的行号?
function notify(request) {
MailApp.sendEmail("youremailhere.com", "Row Added", request.editedRow);
}
function runNotify(e) {
var range = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("Y:Y");
if (e.changeType == "OTHER") {
var request = findRow(e);
notify(request);
}
}
function findRow(e) {
var range = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("Y:Y");
if (e.changeType == "OTHER") {
this.editedRow = range.getRow();
return this;
}
}当与onChange触发器一起使用时,在应用程序脚本中进行更改后,将调用正在编辑的行的工作代码:
function notify(request) {
MailApp.sendEmail("youremail@gmail.com", "Row Added", request.activeRow);
}
function runNotify(e) {
if (e.changeType == "EDIT") {
var request = findTheRow(e);
notify(request);
} else {
return;
}
}
function findTheRow(e) {
var sSht = e.source;
var sht = sSht.getActiveSheet();
var activeRng = sht.getActiveRange();
this.activeRow = activeRng.getRow();
return this;
}发布于 2021-09-20 19:27:59
当通过AppSheet进行更改时,将返回编辑行号的代码:
function notify(request) {
MailApp.sendEmail("youremail@gmail.com", "Row Added", request.activeRow);
}
function runNotify(e) {
if (e.changeType == "EDIT") {
var request = findTheRow(e);
notify(request);
} else {
return;
}
}
function findTheRow(e) {
var sSht = e.source;
var sht = sSht.getActiveSheet();
var activeRng = sht.getActiveRange();
this.activeRow = activeRng.getRow();
return this;
}https://stackoverflow.com/questions/69121517
复制相似问题