- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 12:38 PM - edited 01-17-2023 12:40 PM
Can any one please help me with the query where I can display Latest 5 Change records.
This is as per execution date. Like 2022 change details should be first and then 2021 details.
But when using the below query the details are shuffled.
https://companyname.service-now.com/api/now/table/change_request?cmdb_ci=21effd8d13d61b08c9dfb607614...&sysparm_order=sys_created_on&sysparm_order_direction=asc&sysparm_display_value=true
I also tried the below but couldn't get the desired output
<https://dev27348.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_offset=0>;rel="first",<https://dev27348.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_offset=10>;rel="next",<https://dev27348.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_offset=50>;rel="last"
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 02:38 PM
Hi, your details show a sort field of 'sys_created_on', but your post states execution date; I don't think execution date is an OOB field, is it custom? if yes then this may be the field you need to order by, if not then OOB field 'Actual start' (work_start) might be the field that you want to order by.
Also I am not sure that sysparm_order and sysparm_order_direction are valid for ServcieNow tabble API and I think that you need to roll your sort\order requirement into your sysparm_query
cmdb_ci=21effd8d13d61b08c9dfb6076144b0d1^ORDERBYDESCwork_start
/api/now/table/change_request?sysparm_query=cmdb_ci%3D21effd8d13d61b08c9dfb6076144b0d1%5EORDERBYDESCwork_start&sysparm_limit=5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 02:38 PM
Hi, your details show a sort field of 'sys_created_on', but your post states execution date; I don't think execution date is an OOB field, is it custom? if yes then this may be the field you need to order by, if not then OOB field 'Actual start' (work_start) might be the field that you want to order by.
Also I am not sure that sysparm_order and sysparm_order_direction are valid for ServcieNow tabble API and I think that you need to roll your sort\order requirement into your sysparm_query
cmdb_ci=21effd8d13d61b08c9dfb6076144b0d1^ORDERBYDESCwork_start
/api/now/table/change_request?sysparm_query=cmdb_ci%3D21effd8d13d61b08c9dfb6076144b0d1%5EORDERBYDESCwork_start&sysparm_limit=5

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 03:46 PM
Not sure if possible from the Table API...I know you can do that with GlideQuery objects, but havent investigated if possible to pass it in the Table API in the URL (I mean like javascript:new GlideQuery(.....) ). Still, I believe with a bit of test and trial you could actually do it .
Hope this gives you some hint or ideas.
Cheers,
Joro