Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!