- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 09:59 AM
Hello All,
I have the below email script however, i will like to hide these fields (e.g Description etc) in the email notification when no value is provided. In the email notification, they should be hidden only when no value is provided. What is the logic to achieve this for the below scripts?
1. template.print('<div>Description: ' + (current.sysapproval.variables.description ? current.sysapproval.variables.description.getDisplayValue().toString() : "" )+ '</div><div> </div>');
2. template.print("Summary:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.quantity + " X " + gr.cat_item.getDisplayValue() + " at " + gr.cat_item.price.getDisplayValue() + " each \n");
}
3. Comments: ${sysapproval.comments}
Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 11:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 11:09 AM
Thank you for your help.
I tried but same result in the notification (see below)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 11:31 AM
//try adding a trim()
f (current.sysapproval.variables.description.getDisplayValue().trim()!='')
{
template.print('<div>Description: ' + (current.sysapproval.variables.description ? current.sysapproval.variables.description.getDisplayValue().toString() : "" )+ '</div><div> </div>');
}
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 11:50 AM
try this
if (current.sysapproval.variables.description)
{
...
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 12:58 PM
Thank you, Puneet.
This worked like magic for number 1. I tried to apply the same logic for 2&3 but no luck. Number 2 is a <mail_script></mail_script> in Email Template. How can I apply the same logic to work in email template for 2&3?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2019 08:08 AM
I guess it should work in similar way
if (current.sysapproval)
{
template.print("Summary:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.quantity + " X " + gr.cat_item.getDisplayValue() + " at " + gr.cat_item.price.getDisplayValue() + " each \n");
}
}
if (${sysapproval.comments})
{
${sysapproval.comments}
}