How to bring a field value as a hyperlink on email notification , which on clicking navigate to the current record.???

Servicenow12
Tera Contributor

Field - Ticket number should come as a hyperlink on notification.  I tried with insert link it gives the display value with hyperlink but on clicking it comes as Record not found. I think the URL is not correct...How to make it refer to current record.?? Any help will be appreciated 

 

find_real_file.png

 

find_real_file.png

 

1 ACCEPTED SOLUTION

Hi,

Its because of the display value of the field in the table.

 

Thanks,

Murthy

Thanks,
Murthy

View solution in original post

4 REPLIES 4

Murthy Ch
Giga Sage

Hi,

Just now tested in my PDI you have to use ${URI} or ${URI_REF} in message HTML

Something like below screenshot:

find_real_file.png

Output:

find_real_file.png

By clicking on the hyper link it will take to the created record

The difference between the ${URI} or ${URI_REF} is if you use ${URI} it will print the hyperlink text as LINK or if you use ${URI_REF} it will print the hyperlink text as display field of the triggered table.

 

Check for more info on DOCS

 

 

Thanks,

Murthy

 

Thanks,
Murthy

There are 2 fields actually number and ticket number , if i use URI_REF , it shows for number field..not ticket number

Hi,

Its because of the display value of the field in the table.

 

Thanks,

Murthy

Thanks,
Murthy

If you want to show only ticket number you have to use emai_script.

Sample code below:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var link = createLinkForObject(current.getTableName(), current.getUniqueValue(), current.getValue("u_days_left"));
    template.print("Email Script: " + link);

    function createLinkForObject(strTableName, strSysID, strDays) {
        var url = gs.getProperty('glide.servlet.uri') + gs.generateURL(strTableName, strSysID);
        return '<a href="' + url + '">' + strDays + '</a>';
    }

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

O/p:

find_real_file.png

Thanks,
Murthy