if statement not working in email script

avinashdubey103
Tera Guru

Hi 

I have a  requirement to print description when the  it is not empty.

i have written the script ,but it is getting also when the description is empty. 

 

(function runMailScript(current, template, email, email_action, event) {

          // Add your code here
          var descriptioncheck  = current.description;
          gs.log("TestCheck"+descriptioncheck);

             template.print("<div>Short Description: ${short_description}</div><div style='height:30px;'></div><div>Assignment group: ${assignment_group}</div><div>Assigned to: ${assigned_to}</div><div>Due date: ${due_date}</div><div>Click here to view Task: ${URI_REF}</div><br/><hr></div>");

             if(descriptioncheck !== "")
             {
                template.print("<br/><div>Description: ${description}</div>");
             }



})(current, template, email, email_action, event);
1 ACCEPTED SOLUTION

AshishKM
Kilo Patron
Kilo Patron

Hi @avinashdubey103 ,

Update the if condition and use only “!=“ , test the result.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

2 REPLIES 2

AshishKM
Kilo Patron
Kilo Patron

Hi @avinashdubey103 ,

Update the if condition and use only “!=“ , test the result.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Dhananjay Pawar
Kilo Sage

Hi,

Can you try below code.

 

(function runMailScript(current, template, email, email_action, event) {

 

          // Add your code here
          var descriptioncheck  = current.description;
          gs.log("TestCheck"+descriptioncheck);
if(descriptioncheck !== "")
             {
             template.print("<div>Short Description: ${short_description}</div><div style='height:30px;'></div><div>Assignment group: ${assignment_group}</div><div>Assigned to: ${assigned_to}</div><div>Due date: ${due_date}</div><div>Click here to view Task: ${URI_REF}</div><br/><hr></div>");

 

             
                template.print("<br/><div>Description: ${description}</div>");
             }




})(current, template, email, email_action, event);