Home > Net >  How to send email to myself when a condition is met on Google Sheets
How to send email to myself when a condition is met on Google Sheets

Time:01-19

I'm looking for a way to send an email to myself using a script when a condition is met on a google sheet. I have no idea where to start on this one. What I want to do is when column "i" changes to "Re-apply PGR" instead of "None" to email me when it changes. Here is a copy link to my project if it helps https://docs.google.com/spreadsheets/d/1EkCBCxLIZBToFkdnBpBZenZOsqEg5KaDXVB6nrbEbt0/edit?usp=sharing

CodePudding user response:

Basic onEdit code

If the change is caused by a user edit then you can use the onEdit trigger.[

function onEdit(e) {
  const sh = e.range.getSheet();
  if(sh.getName() == "High Low Temp Option" && e.range.columnStart == 9 && e.range.rowStart > 11 && e.value == "Re-apply PGR" ) {
    //Send email code here
  }
}

CodePudding user response:

Try this:

function checkValue()
{
  var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("High Low Temp Option");

var valueToCheck = sheet.getRange("I:I").getValue();

if(valueToCheck="Re-apply PGR")
{
  MailApp.sendEmail("[email protected]","Testing test","1231323"  valueToCheck  ".");
}
}
  •  Tags:  
  • Related