Display hyperlink instead of full url in URL field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016 10:02 AM
Good morning,
Yesterday I got some help from ctomasi and it's working great! Can we concatinate 2 fields to complete a URL?
Recap.
I have a URL field that is created by concatenating 2 values. For extra credit, I would like to show a hyper link rather than the full ugly URL on the form. Can this be done?
Please advise and thank you!!!
Regards,
Carl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016 02:52 PM
Hi Carl,
Here's my idea (it needs some HTML styling).
Create a UI Macro (System UI> Macro). Mine is called "website". The name matters because it is used as a formatter which you can add to the form.
My simple UI macro looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate jelly="true">
var gr = new GlideRecord(jelly.jvar_ref_table);
if (gr.get(jelly.sys_id)) {
gs.log('url=' + gr.u_url);
}
</g:evaluate>
Website: <a target="_blank" href='${gr.u_url}'>LINK</a>
</j:jelly>
Next, create a formatter (System UI> Formatter)
Make sure the Formatter field is the name of your macro defined above.
Finally, place the field on the form using the usual methods (Configure> Form Layout or Configure> Form Design). You will find your formatter listed with the other formatters (like Activities (filtered)).
Granted, mine's not the prettiest thing, with a little HTML style and table for alignment, it can be better. The top URL is the original field value. The bottom "Website" has a clickable link that opens in a new window.
http://wiki.servicenow.com/index.php?title=UI_Macros
Creating a Formatter - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016 03:00 PM
Wow! Thanks Chuck! I'm going to give it a shot.
I'm also going to try out the solution abhi_r provided.
This looks like it's going to take a while so I'll reply back when I get a chance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016 03:03 PM
Abhi did a great job with the client script. However, I need to point out that his solution uses DOM manipulation which puts it at risk of not working in future releases if the developers decide to change the DOM (again). Mine is all supportable.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016 03:10 PM
I agree with chuck . You are good until your element id does not change
which is very rare.
On Wednesday, September 14, 2016, carlh <community-no-reply@servicenow.com>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2016 02:45 PM
Hi, Chuck,
Your info is great help, just wondering how can we add the current table.field1 to the link rather than just a general url link (www.amazon.com)?
For example, The url field1 is like https://mysite.service-now.com/nav_to.do?uri=incident.do?sys_id=0acc20d24f3a8a00a9ef0f1f0310c7ff&my_... , which field2 is another field in the incident table.
Thanks a lot.
-James