URL field is not clickable in the Service Portal view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 04:13 AM
Hi All,
I have a URL field(u_link_to_full_document) with the below script to update it using Scheduled job, its working fine in UI but its not a clickable link service portal. Kindly help me to resolve this issue.
Note: I have added the 'No Truncate' attribute as well to the URL field.
Script:
pol.u_link_to_full_document = gs.getProperty('glide.servlet.uri') + '/grc?id=lineitem&table=' + pol.getTableName() + '&sys_id=' + pol.parent.sys_id;
My UI view:
My Portal View:
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 04:40 AM
In Service Portal, to make a URL field clickable as a link, you need to ensure that the URL is properly formatted with the HTML <a> tag. You can use a UI Macro or Client Script in ServiceNow to achieve this. In your case, since you are updating the field using a Scheduled Job, you can use a Client Script to format the URL as a clickable link -
(function () {
if (current.u_link_to_full_document) {
var url = gs.getProperty('glide.servlet.uri') + '/grc?id=lineitem&table=' + current.getTableName() + '&sys_id=' + current.parent.sys_id;
var clickableLink = '<a href="' + url + '" target="_blank">Click Here</a>';
current.u_link_to_full_document = clickableLink;
}
})();
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 05:51 AM