How to make the incident number as hyperlink in email notifications

Renu4
Tera Contributor

Hello All,

I would like to make my incidnet number as a hyper link in the mail notifications which is triggered when a comment is added to a ticket

Renu4_1-1695898383416.png

 

the mail script for this is attached below.

 

 

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

    var commentorName = event.parm1;
    var userGr = new GlideRecord('sys_user');
    userGr.addQuery('sys_id', commentorName);
    userGr.query();
    if (userGr.next())
        commentorName = userGr.name;
    var comment = current.comments.getJournalEntry(1);
    var commentTextIndex = comment.indexOf('\n');
    var commentMessage = comment.slice(commentTextIndex + 1, comment.length - 2);
    commentMessage = commentMessage.replace(/\n/g, '<br/>');
    template.print('<div style="line-height: 24px;color:#181A1F;">');
    template.print('<div style="text-align: center; line-height:36px; padding-bottom: 24px;' +
        ' border-bottom: 1px solid #DADDE2;"><span style="font-size: 24px;">' +
        commentorName + ' added a comment to your request</span></div>');
    template.print('<div style="font-size: 16px; padding-top: 24px; padding-bottom: 16px;">' +
        'Hi ' + current.caller_id.first_name + ',</div>');
    template.print('<div style="font-size: 16px; padding-bottom: 16px; ">' +
        commentorName + ' left a comment on ' +
        '<span style="font-weight: 600">' + current.task_effective_number + '</span>:</div>');
    template.print('<div style="font-size: 16px; font-weight: 600;">' + '"' + commentMessage + '"' + '</div>');
    template.print('</div>');

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

 

 

Can someone correct the code please.

1 REPLY 1

Peter Bodelier
Giga Sage

Hi @Renu4 

You can use ${URI_REF} anywhere in the body of your email notification. Using ${URI_REF} takes the display value for the linked record and uses that for the link text.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.