- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:48 AM
Hi Team,
I have created some variables and applied UI policies for them. However, I need the notification body to display "NA" values if the variables are hidden at the form level due to the UI policy. This means that if the variables are not submitted, their values should appear as empty in the notification body.
How Can I achive empety variable as "NA" In notification Body,Can you help on that
Thank you in adavance
Thank you
Sivananda Reddy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:55 AM
something like this in email script of RITM notification
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('RITM Variables: <br/>');
var variables = current.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if (label != '' && value != '') {
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
} else if (value == '') {
template.space(4);
template.print(' ' + label + " = " + 'NA' + "<br/>");
}
}
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:53 AM
you can use email script and check if the variable value is empty then print NA
What did you start with and where are you stuck?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:55 AM
something like this in email script of RITM notification
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('RITM Variables: <br/>');
var variables = current.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if (label != '' && value != '') {
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
} else if (value == '') {
template.space(4);
template.print(' ' + label + " = " + 'NA' + "<br/>");
}
}
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 11:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 05:58 AM
Hello @Siva82 ,
You can call an email script in your notification.
How to call email script from email notification this you can find in the below
https://www.servicenow.com/community/developer-forum/how-to-call-email-script-to-notification/m-p/18...
and then in email script you can directly access variables and check for the variable value something like the below
for example your variable name is x which is hided on the form and you want to print the value as NA for the same then you can write the below in your email script
var x = current.variables.x;
if(x=='')
{
template.print("X : "NA");
}
the above script will print NA if the value sof x is blank.
Note:Please replace the backend name of your variable "X" where "x" is present.
Please mark it as correct/useful if this helped you.
Regards,
Debasis