We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

URL field is not clickable in the Service Portal view

Lavanya Nagendr
Giga Guru

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:

Screenshot 2023-09-19 at 5.57.34 PM.png

 

My Portal View:

 

Screenshot 2023-09-19 at 6.02.21 PM.png

 

Thanks!

 

2 REPLIES 2

Tushar
Kilo Sage

Hi @Lavanya Nagendr 

 

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

Hi @Tushar  ,

 

I have tried you're code, it still didnt work,

 

Screenshot 2023-09-20 at 6.19.17 PM.png