Display value for URL in List View / Report

garyopela
ServiceNow Employee
ServiceNow Employee

Hello, I have been asked by a process owner to add a field to Project, which, when clicked from a report, would open a window of all tasks under that project. I have it figured out, but it's not pretty.

 

What I did was add a calculated field with the following calculation:

 

<code>

var link = "https://instance.service-now.com/pm_project_task_list.do?sysparm_query=parent%3D" + current.sys_id + "%5E";

javascript:"<a href=" + link + "> Tasks </a>";

</code>

 

It works great when you look at the field on the form. It shows up as "Tasks" and if you click on it, it directs you to the URL. The problem is that the lists and the reports are stripping the HTML (I'm sure it is to prevent HTML injection).

 

I need a way around this. I want the link to display in list and report view as 'Tasks' and be clickable. Also because it is not executing the HTMl in the table, the links are incorrect because of the a hrefs. I can replace all that with just the link itself, but that is very ugly when looking at it in a list.

 

Anyways, bottom line is that I want to replicate the a href functionality in the lists and reports. Any suggestions are welcome.

11 REPLIES 11

Gary, I am running into this requirement as well.   Being able to display a URL/HTML(containing <a>) field in a list/report view is a challenge.



Were you able to get this to work?   Any input would be great, thank you!



Raghu


garyopela
ServiceNow Employee
ServiceNow Employee

Raghu, no, we were never able to get it to work. I think it is for security reasons though that the HTML elements aren't rendered as HTML.


Alex Macdonel
Tera Expert

Just got a request to implement something similar - provide a URL to the record on the list view.



Has anyone been able to look further / implement this?



Alex


Can you please describe the requirement you are working on in a litlle bit more detail? Thanks.


The ask is to include a URL to the ticket so that when the list view is exported to a CSV or Excel file there's an easy way to go back to the task record.



I found a solution (not what is being asked for but good enough) to what I'm asking; I can add a calculated field with the following:




current.sys_id




the requester can then manipulate the sys_id field that has been exported to construct a URL like so:


https://<instance>.service-now.com/nav_to.do?uri=task.do?sys_id=<sys_id>



Cheers!