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

164
Views
"!=" 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 answers
Answer question

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 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!