Trying to add display text to a URL field type

jefff1
Kilo Explorer

Hi Community,

 

I have a script that is populating a HTML link into a field type of URL.   The script and link are working perfectly but since the full URL in the link column takes up a good portion of list view screen, I'm trying to figure out if it is possible to change the syntax to use a displayed text string instead of the full link yet keep the link functional.   Trying to incorporate <a href> tags doesn't work.   I'm wondering if anyone else has done this or has any ideas.

 

Thank you,

 

Jeff Franklin

 

Simplified Code Excerpt:

var myLink=gs.getProperty('glide.servlet.uri') + 'time_card_list.do?sysparm_query=user.name%3D' + myList[c-1][1];

tcs.u_link = myLink;

tcs.insert();

10 REPLIES 10

Any updates to this?



Having a similar issue trying to use the UI Action on the List View.



Jeremiah Selander


Nithya Sivaram1
Kilo Contributor

Also, Make Isolate Script to false for the UI Policy otherwise document.getElementByID  will not work in Servicenow

 

 

Nithya.

AdamBrushett
Tera Expert

Hi,

 

I'm trying to do a very similar thing on the core_company table with a new URL field, using the following script:

 

function onCondition() {
         document.getElementById("core_company.u_url_1").innerHTML = "Click here";
}

But it's not working, I notice that if I inspect the element in my browser the id is actually 'core_company.u_url_1_link', I've also tried this as the id above but still no luck.

 

I know the script is firing because I tested it with a simple alert("Hello World"); so the UI Policy is otherwise configured correctly.

 

Any one know why this wouldn't work?

 

Regards,

 

Adam...

 

Hi Adam,

Did you happen to set the Isolate script to False? That checkbox is not on the form, I have changed it on the list layout of the UI Policy.

Also for each field, it is needed to append "_link", that is why it wasn't working for me.

Pavel

Hi,

 

I don't recall trying that, like you say it's not on the form.  I tried the "_link" to no avail. 

But I've changed it completely now so that I don't have this problem anymore, but I'll bare it mind if I ever try something like this again!  Thanks...