- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 08:54 AM
Hi everybody,
I tried to look into sections of API documentation where I can possibly find the answer, but failed to find the answer.
So how do you get the URL to a record through it's sys_id? Is it possible? What class/function does ServiceNow offer to do this?
ServiceNow can generate URL out of record, so I believe it can be done in script (I hope so).
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 10:12 AM
Hi Chuck,
Chuck Tomasi wrote:
If you have the table name and sys_id, then the URL is a simple matter of putting the pieces together.
var url = "/" + table_name + '.do?sys_id=' + sys_id;
For example, a specific incident record can be addressed like this:
/incident.do?sys_id=90431616dbe222002e38711ebf9619f7
I already have this, and doable with gs.generateURL(tablename, sys_id)
The reason why I asked that is because I have a field that references to Task table (and therefore, can be filled with sys_id coming from tables: Incident, Service Request, Problem, etc. and that makes it difficult to generate URL from that field.
But I think I've figured out the solution myself now: I just get the value of Number field from the referenced Task record, check the prefix of Number (if it starts with TASK, INC, PROB, etc.) and that's where my script can conclude the table name.
Thanks to your responses
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2018 02:07 PM
Hi Chuck,
does this work for getting the URL for a report...or some variance of this script equation you posted? I'm not looking for the URL of the record of the report, but the report itself. I'm trying to script a report into the HTML of a dynamic block so that I can present a report on a page in MyService. Thanks in advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2018 07:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 09:30 AM
Excellent, thanks so much Chuck!
By the way, really dig your TechNow videos!
One more question if I may, is there a way to dynamically control the height of the iFrame holding the report in the HTML so that it has a vertical space equal to the number of records? As opposed to hard coding a height for the frame that then presents a scroll bar if the number of records is greater than the frame height.
Right now my script looks like this:
<iframe style="position:relative;top:0px;width:100%;height:250px;" border="0" frameborder="0" scrolling="yes" id="task_frame" name="task_frame" allowtransparency="true"
src="sys_report_display.do?sysparm_report_id=d2f5a8fedb2787803c6873e1ba961923"></iframe>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2018 05:53 AM
Not that I know Patrick. The iframe is simply a dumb container. To make it dynamic, you would need to know what content is in it. Which, to my knowledge, isn't part of what you can do with an iframe. It would be like saying "display a YouTube video in this iframe, and based on the resolution, make it change size." You would first need to query YouTube, or in your case, find out what's on the report, then construct your iframe. If you're going to do that, then why use an iframe?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2018 08:07 AM
OK, that makes sense. So is there a better way to display a list of records type report in a CMS page than using an iframe? Specifically I'm building a Dynamic Block content...and am for now using <iframe> in the HTML to place a report on a CMS page. Do you know a better way to place a report in a Dynamic Block? thanks for your help.