首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >查找通过changetype = other进行的更改的行号

查找通过changetype = other进行的更改的行号
EN

Stack Overflow用户
提问于 2021-09-09 16:08:14
回答 1查看 38关注 0票数 1

当为changeType == "OTHER"时,我需要能够调用发生更改的行号。下面是一个测试脚本(在更改时通过runNotify触发),它应该通过电子邮件发送给我进行更改的行号,但它只返回"1“作为行号。我遗漏了什么,使它无法返回已更改行的行号?

代码语言:javascript
复制
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触发器一起使用时,在应用程序脚本中进行更改后,将调用正在编辑的行的工作代码:

代码语言:javascript
复制
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;
}
EN

回答 1

Stack Overflow用户

发布于 2021-09-20 19:27:59

当通过AppSheet进行更改时,将返回编辑行号的代码:

代码语言:javascript
复制
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;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69121517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档