I've been working on a script for google sheets that will trigger 3 different emails depending on 3 different columns. In the 1st column I want the email to send whenever any edits have been made in it. For the 2nd and 3rd, I only want the email to be sent when a specific text has been written. However, the 2nd and 3rd columns are sending emails no matter what has been written in them.
Here is the code so far, thanks in advance!
function sendMailEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("REVIEW");
const rData = e.source.getActiveSheet().getRange(e.range.rowStart,1,1,24).getValues();
let useremail = rData [0][22]
...
if (e.range.columnStart == 8){
MailApp.sendEmail({
to: "abc@gmail.com",
subject: "Global - New Account Access Request",
htmlBody: msg,
noReply: true
});
}
else if (e.range.columnStart == 15 || e.value == "BIZ APPROVED"){
MailApp.sendEmail({
to: "123@gmail.com",
subject: "Global - New Account Access Request",
htmlBody: msg2,
noReply: true
});
}
else if (e.range.columnStart == 19 || e.value == "RISK APPROVED"){
MailApp.sendEmail({
to: useremail,
subject: "Global - New Account Access Request",
htmlBody: msg3,
noReply: true
});
}
}