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

129
Vistas
Google App Script IF statement for Sending Emails

Just want to ask some help regarding with my coding in Google App Script.

Objective: Am trying to send emails once I satisfy the 3 condition (the 2 condition is in the same column). And once the script already sent an email to that specific control number the script shouldn't send again to that transaction. However it still sending emails even if the script already sent to that transaction. I can't find where the problem is or if am not satisfying the condition I set.

Column SubmissionStatus have "Final, Cancelled, Draft" Column processBy have ("ADMIN" only)

  if (submissionStatus !== "Draft" && processBy !== "") { // Prevents sending duplicates  
  var subject = "Cash_Advance ";
  MailApp.sendEmail(currentEmail, subjectline, messageBody);
  sheet.getRange(startRow + i, 38).setValue(EMAIL_SENT +" "+ Date()); // column AL
  // Make sure the cell is updated right away in case the script is interrupted
  SpreadsheetApp.flush();
  } //close if statement

  if (submissionStatus !== "Cancelled" && processBy !== "") { // Prevents sending duplicates  
  var subject = "Cash_Advance ";
  MailApp.sendEmail(currentEmail, subjectline, messageBody);
  sheet.getRange(startRow + i, 38).setValue(EMAIL_SENT +" "+ Date()); // column AL
  // Make sure the cell is updated right away in case the script is interrupted
  SpreadsheetApp.flush();
  } //close if statement
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can simply merge those two if statement into one, maybe that's why it is sending email more than once.

By using submissionStatus === "Final"

In context of your latest edit:-

Column SubmissionStatus have "Final, Cancelled, Draft" Column processBy have ("ADMIN" only)

Modification:

if (submissionStatus === "Final" && processBy !== "") // Prevents sending duplicates  
{ 
          var subject = "Cash_Advance ";
          MailApp.sendEmail(currentEmail, subjectline, messageBody);
          sheet.getRange(startRow + i, 38).setValue(EMAIL_SENT +" "+ Date()); // column AL
          // Make sure the cell is updated right away in case the script is interrupted
          SpreadsheetApp.flush();
 } //close if statement
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