I am trying to figure out what's went wrong with my Google Apps Script. I am trying to send the email when any of cells in column 2 is no longer have "-" in it while the next cell is "No". Apparently, sendEmail function is not working for some reason.
I make little example of small spreadsheet below. I want to send the email when third row is matched.
1 2 3
1 00 - Yes
2 00 - No
3 00 x No
Here is my code:
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet4" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
var nextCell = r.offset(0, 1);
if(( r.getColumn() == 2 ) && ( r.getValue() !== '-' ) && ( nextCell.getValue() === 'No' )){ //checks the cell
MailApp.sendEmail('example@gmail.com', 'test email from Google Spreadsheet', 'Let me know if this came through ok');
}
}
}