Blank value on email notification

Hafsa1
Mega Sage

I have notification which trigger based on case variables.

Requirement is , if value is blank for any field value configured in email body it should come as "Not Application".

How to achieve it?

1 ACCEPTED SOLUTION

Hello @Hafsa1 

For your requirement you can write script as below:

// Check Requestor Name
var requestorName = (current.contact_name_1.nil() && current.contact_name_2.nil() && current.contact_name_3.nil()) ? "Not Application" : (current.contact_name_1 || current.contact_name_2 || current.contact_name_3);

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Hafsa1 

please share some details

1) how are you sending email?

2) email notification is on which table?

3) are you using some script? if yes then you will have to use email script and check if variable value is blank then print "Not Application"

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Viraj Hudlikar
Giga Sage

Hello @Hafsa1 

 

The notification you are sending is it using direct variables over email body? If yes, to achieve this in ServiceNow, you can use email scripts to check if a field value is blank and replace it with "Not Application" in the email body.

 

You can check about email scripting in notification over this link - Example scripting for email notifications

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Hello @Hafsa1 

For your requirement you can write script as below:

// Check Requestor Name
var requestorName = (current.contact_name_1.nil() && current.contact_name_2.nil() && current.contact_name_3.nil()) ? "Not Application" : (current.contact_name_1 || current.contact_name_2 || current.contact_name_3);

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Hafsa1
Mega Sage

it is in table "sysapproval_approver".

on RP, we have created 3 separate variable sets. Based on condition  variable sets populate. At one point of time only 1 variable set can populate and user will fill values based on country. I have added common variables from each variable set as below. but in some case if all 3 variables are blank i want it to give "Not applicable" as text instead on blank.

Requestor name

 

${sysapproval.contact_name_1}
${sysapproval.contact_name_2}
${sysapproval.contact_name_3}

Requestor email

${sysapproval.variables.email_address_for_ordering_1}

${sysapproval.variables.email_address_for_ordering_2}

${sysapproval.variables.email_address_for_ordering_3}

Attach  documentation 

 

${sysapproval.variables.u_attach_documentation_1}
${sysapproval.variables.u_attach_documentation_2}
${sysapproval.variables.u_attach_documentation_3}

Attach screening documentation 

${sysapproval.variables.attach_screening_documentation_1}
${sysapproval.variables.attach_screening_documentation_2}
${sysapproval.variables.attach_screening_documentation_3}