I am trying to write a script to send an E-mail, upon certain column gets edited on google spreadsheet.
its a vacation request (submitted by google forms), when an employee asks for a vacation, the google sheet checks his available balance, if its sufficient or not, if not sufficient i need to send an automated e-mail without interference from the user. and if sufficient balance is available then upon editing (droplist) i want to send e-mail with the result.
Here is the sheet :
https://docs.google.com/spreadsheets/d/18sLrOtzfFsdl0j74W7Iiym4Tg63cSFSWL94i148EA0E/edit?gid=1472164239#gid=1472164239
TAB (REQUESTS)
COLUMN k : the droplist
column S: is the final status whether the balance is sufficient or not , and if sufficient what is the response of the user (Admin) on the vacation.
column Q: subject of e-mail.
column R : body of e-mail.
column A: e-mail address.
function sendMailEdit(e){
var myAliases = GmailApp.getAliases()
if (e.range.columnStart == 18 || e.value != "Approved") return;
const rData = e.source.getActiveSheet().getRange(e.range.rowStart,1,1,20).getValues();
let subj = rData[0][16];
let body = rData[0][17];
let emadd = rData[0][0]
Logger.log(subj)
GmailApp.sendEmail(emadd,subj,body,{from: myAliases[0],name: "MacroFit Coaching",cc: "[email protected]"});
}
function sendMailrEdit(f){
var myAliases = GmailApp.getAliases()
if (f.range.columnStart == 18 || f.value != "Rejected") return;
const rData = f.source.getActiveSheet().getRange(f.range.rowStart,1,1,19).getValues();
let subj = rData[0][16];
let body = rData[0][17];
let emadd = rData[0][0]
Logger.log(subj)
GmailApp.sendEmail(emadd,subj,body,{from: myAliases[0],name: "MacroFit Coaching",cc: "[email protected]"});
}
function sendMailerEdit(g){
var myAliases = GmailApp.getAliases()
if (g.range.columnStart == 18 || g.value != "Partial approval") return;
const rData = g.source.getActiveSheet().getRange(g.range.rowStart,1,1,19).getValues();
let subj = rData[0][16];
let body = rData[0][17];
let emadd = rData[0][0]
Logger.log(subj)
GmailApp.sendEmail(emadd,subj,body,{from: myAliases[0],name: "MacroFit Coaching",cc: "[email protected]"});
}
Sherif Osama is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.