I'm looking for a way to trigger an automatic email notification to myself when any value within a column of data ("Column H") drops below a certain threshold. Ideally, the notification would include the name associated with the value, which is stored in a separate column of the spreadsheet ("Column A").
My best guess so far is that I need to use an onEdit function, which has a condition that checks the values within the specific column and then sends a email when a value meets that condition.
Here's what I have so far, but I'm having issues with completing this.
function onEdit(e){
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange("H1:H200").getValues();
var newValue = e.value;
}
if (newValue < "10"){
MailApp.sendEmail("[email protected]","TEST", "TEST");
}
Any help would be appreciated. Thanks!
Update: Here's what I currently have, following the creation of an installable trigger. I'm getting a 'value' undefined error at the moment and think that possibly syntax/formatting are to blame.
function createSpreadsheetEditTrigger(){
var ss = SpreadsheetApp.getActive();
ScriptApp.newTrigger(StationeryEdited)
.forSpreadsheet(ss)
.onEdit()
.create();
}
function StationeryEdited(e){
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getRange(2, 8, 200, 1).getValues();
var newValue = e.value;
if (newValue < "10"){
MailApp.sendEmail("[email protected]", "TEST", "TEST");
}
}