Email template - if statement scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2014 07:36 PM
Good morning,
I have been tasked to tidy up our companies email templates, I have a question I would like assistance with regarding scripting.
I would like to know if I can create an IF statement so that priority 1 incidents are followed by the urgency state. For example:
IF priority 1, then display urgency
So it shows as Priority 1 HIGH.
Our company have specific needs to be able to show the incident state next to priority 1, but having looked on the servicenow help pages I don't see anything like this.
I hope you can help.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2014 02:18 AM
Hello,
You can write if condition in email notification using <mail_script>. Please refer below script for your reference:
<mail_script>
if(current.priority == '1')
template.print("Priority 1 HIGH);
</mail_script>
For more information on scripting for email notification, please refer below wiki:
Scripting for Email Notifications - ServiceNow Wiki
Please mark answer as correct/helpful, if it is really helpful
Regards,
Solutioner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2014 07:20 AM
The trick with email notifications is adding the <mail_script> tag anywhere you'd like to drop into JavaScript. If you do that, then it behaves much like regular business rules.
Here is a great article that I think will help you understand how this works. It takes away some of the mystery associated with email scripting: Scripting for Email Notifications - ServiceNow Wiki
This is an example of the script that you might use:
<b>Priority: </b>${priority}
<mail_script>
if(current.priority == '1')
template.print(current.urgency);
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2014 01:25 PM
Thanks, understand.
template.print('<td bgcolor="#3A5894"><b><font face="Default Sans Serif" color="#FFFFFF" size="2">Severity:</b></font></td>');
template.print('<td valign="top" bgcolor="#AABBDE"><font face="Default Sans Serif" size="2">');
template.print('' + current.priority.getDisplayValue() + "\n"); IF STATEMENT HERE
template.print('</font></td>');
That is what I have so far - I am not sure that the above will help.