vendredi 28 août 2020

Trying to Run two functions and two different emails in google scripts

I'm trying to have my sheet trigger an email alert when the last row on certain column matches an if statement after a google form feeds the sheet. it worked the first time but when i try to do a second condition it only acomplishes the second if. so separated the ifs work, but not combined.

can you guys help? here is the function:

function sendEmails() {
  
  var ss  = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Observaciones Diarias IMPRG");
  var lr  = ss.getLastRow();
  
  var currentTemp = ss.getRange(lr, 6).getValue();
  var currentkidName = ss.getRange(lr, 3).getValue();
  var currentTexture = ss.getRange(lr, 15).getValue();
  
  if(currentTemp >39) {
  
  MailApp.sendEmail("alvaroalfredo25@gmail.com","Temperature>39°Alert", currentkidName + " had atemperature of " + currentTemp + "° " +" which is extremely high, please check")
  }
  
  else if (currentTexture = 1){
    MailApp.sendEmail("alvaroalfredo25@gmail.com","Texture Alert", currentkidName + " had a  " + " liquid Evacuation. which indicates an issue, please check")
  }
}

Aucun commentaire:

Enregistrer un commentaire