Converting a URL into hyperlink in Work Notes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 10:37 AM
Hello,
I have a requirement where I want to convert a URL that is added into Work Notes of an incident into Hyperlink. The users who will be adding these links will not have the capability to add HTML tags to the link before submitting.
I have created a business rule before insert update and condition when work notes changes. Below is the script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var linkTemplate = '[code]<a href="$1" target="_blank">$1</a>[/code]';
current.work_notes = current.work_notes.replace(exp, linkTemplate);
})(current, previous);
This code is working, however it shows like this below after clicking on Submit in Work Notes.
I would just want the Hyperlink but not the URL text.
Any insights on what the issue could be in the script would be great. I got this script from one of the community questions on a similar issue but do not have a solution for this.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 10:52 AM
It sounds like you want to automatically convert plain text URLs into clickable hyperlinks in the Work Notes field of an incident in ServiceNow. Here are some potential solutions to this problem:
Use the "Autolink" feature in ServiceNow: ServiceNow has a built-in feature called "Autolink" that can automatically convert plain text URLs into clickable hyperlinks. You can enable this feature for the Work Notes field by going to System Definition > Dictionary and finding the Work Notes field. Then, in the Attributes section, set the "Autolink" field to "true" and save your changes.
Use a third-party plugin: Another option is to use a third-party plugin that can automatically convert URLs into hyperlinks in ServiceNow. There are several such plugins available on the ServiceNow Store, and many of them offer a free trial or a free version with limited functionality. You can search for "hyperlink" in the ServiceNow Store to find a plugin that meets your needs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 11:14 AM
Sorry Veer accepted the solution by mistake but I do not see Autolink Option in the Attributes section. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 11:28 AM
add autolink=true in dictionary attribute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 11:52 AM
I have done that and nothing happens
If I helped you with your case, please click the Thumb Icon and mark as Correct.