How to create ‘Take me to my Ticket’ button in email notification?

In ServiceNow, email notifications are one the easiest way to inform user about a change that have happened to ticket or case. a frequent ask we receive as ServiceNow professionals is that our customers want to be able to click on link or button that shows newly updated/created ticket.

OOTB you can use ${URI_REF} to have clickable link back to ticket, however it doesn’t look great in terms of styling. I created the email script below which leverage some of the code written in OOTB incident_take_me_to_the_incident email script, the script is generic so it can be used in most use cases.

(function runMailScript( current, template, email, email_action, event) {
	var link = current.getLink();
	template.print('<font face="helvetica">');
	var backgroundColor = 'background-color: #278efc;';
	var border = 'border: 1px solid #0368d4;';
	var color = 'color: #ffffff;';
	var fontSize = 'font-size: 14px;';
	var fontFamily = 'font-family: Helvetica, Arial, sans-serif;';
	var textDecoration = 'text-decoration: none; border-radius: 3px;';
	var webKitBorder = '-webkit-border-radius: 3px;';
	var mozBorder = '-moz-border-radius: 3px;';
	var display = 'display: inline-block;';
	var padding = 'padding: 5px;';
	template.print('<a href="' + link + '"');
	template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding);
	template.print('">');
	template.print(gs.getMessage('Take me to my Ticket'));
	template.print('</a>');
	template.print('</font>');
})(current, template, email, email_action, event);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s