Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
"!=" and "is blank" not working as expected

Can you please help me correct me app script code?

function sendEmails() {

  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var lr = ss.getLastRow ();
  

  for (var i=2;i<=lr;i++)
  {

    var currentemail =ss.getRange (i,1).getValue();
    var currentclasstitle =ss.getRange (i,3).getValue();
    var currentcondition =ss.getRange (i,4).getValue();
    var Confirmation =ss.getRange (i,4).setValue("Email Sent");

    if (currentcondition!="Email Sent"&& currentemail !=""){

    MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");}
    else if (currentemail!="") {Confirmation}
  }
  
}

everything not showing correctly after else if statement

what I want is

**

  • IF A3 is BLANK I WANT D3 also to be BLANK

**

as per my above code, even if A3 is blank D3 populates email sent

Google SS screenshot

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

That's because you're setting value in D3 before your If statement

Replace this:-

    var Confirmation =ss.getRange (i,4).setValue("Email Sent");

    if (currentcondition!="Email Sent"&& currentemail !=""){

    MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");}
    else if (currentemail!="") {Confirmation}

with this:-

    const confirmation = ss.getRange (i,4)
    if (currentemail !== "" && currentcondition !== "Email Sent" )
    {      
      MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");
      confirmation.setValue("Email Sent");
    }

Reference:

if..else

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda