最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to reference a cell to the left of active cell in Google script - Stack Overflow

programmeradmin0浏览0评论

Need to reference a cell in an email subject.

Need to reference the cell left to the active cell i.e if cell in column B is changed, reference cell in same row in column A.

All of the code works apart from

var productname = range.getvalue("A"+range.getRow);

Would be very grateful if someone can point out as to where I am going wrong! Sure this will be very easy for someone that knows what they are doing.

function onEdit(e) {
    
      var range = e.range;
      
      if(range.getValue() < 100) {
        var productname = range.getvalue("A"+range.getRow);
        var message = "Product variant" + productname + "has dropped to " + range.getValue();
        var subject = "Stock Notification";
        var emailAddress = "[email protected]";
        MailApp.sendEmail(emailAddress, subject, message);
       
      }
    }

Need to reference a cell in an email subject.

Need to reference the cell left to the active cell i.e if cell in column B is changed, reference cell in same row in column A.

All of the code works apart from

var productname = range.getvalue("A"+range.getRow);

Would be very grateful if someone can point out as to where I am going wrong! Sure this will be very easy for someone that knows what they are doing.

function onEdit(e) {
    
      var range = e.range;
      
      if(range.getValue() < 100) {
        var productname = range.getvalue("A"+range.getRow);
        var message = "Product variant" + productname + "has dropped to " + range.getValue();
        var subject = "Stock Notification";
        var emailAddress = "[email protected]";
        MailApp.sendEmail(emailAddress, subject, message);
       
      }
    }
Share Improve this question edited Dec 8, 2024 at 10:01 marc_s 755k184 gold badges1.4k silver badges1.5k bronze badges asked Nov 17, 2014 at 15:11 adamsportstechadamsportstech 3472 gold badges5 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Try

var productname = range.offset(0,-1).getValue();

However, you may have to 'limit' the trigger to a certain sheet and even a certain column (col B ?)

发布评论

评论列表(0)

  1. 暂无评论