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(gs.getMessage('Take me to my Ticket'));
})(current, template, email, email_action, event);


  1. This is very useful. I have noticed it has the same problem as the “take me to the incident” mail script where it strips the page of its navigation. I would like the functionality of URI_REF but with the esthetics of the solution you posted. How would someone accomplish this?


    1. Hi Chris, I had the same requirement. Replace the link variable with the following:

      var link = ‘’ + current.getLink();

      That will take you to the console with the navigation menu.
      We decided to forward users to the portal instead which is another option.


  2. Hi Ahmed,
    this looks fantastic! Could you maybe direct me, as I’m quite new to scripting, how to modify the given url link variable so it takes me to the Employee Service Center view of the record…?
    Thank you very much in advance,


Leave a Reply

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

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

Facebook photo

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

Connecting to %s