I have been trying to find an answer for this specific problem and I can not find the right answer. I have a spreadsheet and I want it to send an email every time the cell data is modified in the L column of a particular sheet, I have a project activator for this particular case that triggers the function when editing the sheet. calculation. This is the result:
function sendNotification() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var cell = ss.getActiveCell().getA1Notation();
var row = sheet.getActiveRange().getRow();
var column = sheet.getActiveRange().getColumn()
var cellvalue = ss.getActiveCell().getValue().toString();
var recipients = "[email protected]";
var message = '';
//column L is number 12, when the result is zero it won´t enter the if
if(column-12){
//do nothing
message='no hago nada'
}
else{
//Only if I am in this specific sheet
if(sheet.getName()=='Olmedo Trabajos de Pepe'){
//Only if the cell is not empty
if(cellvalue!=''){
var subject =' Fotos de promoción: ' + sheet.getRange('G'+ sheet.getActiveCell().getRowIndex()).getValue();
var body = ' Promoción: ' + sheet.getRange('G'+ sheet.getActiveCell().getRowIndex()).getValue() +'\n Pedido de Olmedo ' + sheet.getRange('A'+ sheet.getActiveCell().getRowIndex()).getValue() + '\n Oferta Panorama ' + sheet.getRange('m'+ sheet.getActiveCell().getRowIndex()).getValue() +'\n Ya tiene fotos en la dirección \n' + sheet.getRange('L'+ sheet.getActiveCell().getRowIndex()).getValue();
//Then I´ll send an email with the information from the table.
MailApp.sendEmail(recipients, subject, body);
}
}
}
};
As you can see, as a result of my ignorance of Javascript, there are things that are not very ugly, like doing 3 if instead of one because I have not found a way to concatenate all the conditions into one (I tried with "& & ").