Email Notification to send include link as hyperlink instead of HTML plain text for external URLs

Community Alums
Not applicable

Hi 

Need quick help with suggestions or any reference for below use case:

 

" Need to send URL Link as hyperlink in email notification from activity log of task table instead of HTML plain text with codes. The URL link will direct to other application as it's not from SN platform rather for different application."

 

Dashboard: [code]<a href="https://cyz.com/d/&orgId=1&refresh=1m&var-DB=argos-muc9&var-namespace=o=1700735762000" target="_blank">click here to see the dashboard</a>[/code]

UI: [code]<a href="https://xyz.net/projects/D=udi-synchro-tst" target="_blank">click here to go to UI</a>[/code]

 

NOTE: Have tried and explore the URI and URI_REF since the reference is not for ServiceNow record for any field it doesn't help.

 

Thanks for all help

1 ACCEPTED SOLUTION

Chetna_dev
Kilo Sage

Here is the Reference Code: @Community Alums 

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

// Remove the [code] tag from HTML hyperlink from incident activity log to send notification as link

var lastcomments = current.u_last_comment;
var apendcmntLink = lastcomments.replace(/\[code\]/g, '').replace(/\[\/code\]/g, '<br/>');
template.print(apendcmntLink + '\n');

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

View solution in original post

3 REPLIES 3

Chetna_dev
Kilo Sage

Hiii @Community Alums 

Seems you are passing HTML syntax [code] [/code] within your update in activity log of incident that hamper when it send as notification and result to plain text.

Suggest to try by removing the [code] tag from your notification and giving it a try.

Hint: Try to create an email script for u_last_comment or comment that send for notification for activity log update and pass the email script instead of field 'u_last_comment'

You can use regex command to remove the HTML tag in your email script.

Hope it helps.

Chetna_dev
Kilo Sage

Here is the Reference Code: @Community Alums 

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

// Remove the [code] tag from HTML hyperlink from incident activity log to send notification as link

var lastcomments = current.u_last_comment;
var apendcmntLink = lastcomments.replace(/\[code\]/g, '').replace(/\[\/code\]/g, '<br/>');
template.print(apendcmntLink + '\n');

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

Tony Chatfield1
Kilo Patron

Hi, the solution would be to construct your link in a Notification Email Script and then add this to the notification message.

Scripting for email notifications (servicenow.com)

Examples from a PDI

/sys_script_email_list.do?sysparm_query=scriptLIKEhref&sysparm_view=