How to make incident number hyper link in notification message

sinu2
Tera Expert

In the email notification, make the Incident ticket number a hyperlink to the record on the platform.

how to make hyper link below incident number

 

sinu2_0-1693893021937.png

 

4 REPLIES 4

Aman Kumar S
Kilo Patron

Hi @sinu2 

Use ${URI_REF} instead of ${number}

 

It will give you a hyperlink with incident number.

To understand how these work, navigate to below link:

https://servicenowguru.com/system-definition/email-notifications-system-definition/email-links-uri-u...

 

Mark the response as helpful & correct if it resolves your issue, so the thread can be close.

 

Vishal Birajdar
Giga Sage

Hello Sinu,

 

1. You need to write Notification email script.

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,/* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,/* Optional GlideRecord */event) {

/*Assuming your notification run on incident table*/
    var sysId = current.getValue('sys_id');
    template.print('<a href="' + gs.getProperty('glide.servlet.uri') + 'incident.do?&sys_id=' + sysId + '">' + '${number}' + '</a>');

})(current, template, email, email_action, event);

 

2. Call this mail script in your notification template

 

incident #: ${mail_script:<"name of your mail script">}

 

 

 

Teju Dhoran
Kilo Sage

Hi

We can use ${URI_REF} and hyperlink would be created for the display field of record which in this case would be Incident number.
Please check below link:

https://www.servicenow.com/community/developer-forum/how-to-make-the-ticket-number-as-hyperlink-on-a...

Siva Jyothi M
Mega Sage

Hi @sinu2,

 

You can use ${URI_REF} and it redirects to the Native UI and if you want to redirect it to the workspace view, you need to create a email script for this. Below is a sample.

(function runMailScript(current, template, email, email_action, event) {

// Build the link format
var attachLink = '<a href=/sp?id=ticket&sys_id=' + current.sys_id;
attachLink += '&table=table_name';//Keep the table name here
attachLink += '>here</a>';

// Print the link text
template.print(attachLink);

})(current, template, email, email_action, event);

Mark this answer as correct and helpful if it solves your issue.

 

Regards,

Siva Jyothi M.