Need help in adding a link in String type field

Pihu1
Tera Contributor

Hi Community,

I need help in adding a link in String type field. How can we store a link/add a link in String type field ?

Any help would be greatly appreciated.

Thanks

Pihu

6 REPLIES 6

Harsh Vardhan
Giga Patron

String field does not hold hyperlink on form. May i know the use case ?

 

if you are looking on list view there is workaround. 

 

http://www.john-james-andersen.com/blog/service-now/making-linky-lists-in-servicenow-list-views.html

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

A string type field cannot hold a link(or any html)

You can create a URL field, or you can create a HTML type of field.

Link can be stored in work notes/comments, ie. journal fields.

-Anurag

-Anurag

sachin_namjoshi
Kilo Patron
Kilo Patron

You can do it with onload client script.

Below is the example script.

 



The below script assumes the name of the field is "u_url" and it has a value of "Click here".



function onLoad() {
g_form.getControl('u_url').style.color = 'blue'; // Set text font color to blue
g_form.getControl('u_url').style.textDecoration = "underline"; // Set text decoration to underlined
g_form.getControl('u_url').onmouseover = mouseOver; // Set mouseOver cursor style
g_form.getControl('u_url').onclick = urlFunction; // Set onclick to the redirect url
}

function mouseOver() {
this.style.cursor = 'hand'; // Set onmouseover cursor style
}

function urlFunction() {
window.top.location.href = 'http://www.google.com'; // This is the url that the user will be redirected to
}

Regards,
Sachin

After clicking that is not getting opened in next tab

Yogita11__0-1730790044820.png