
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2016 05:13 AM
Hello All,I want to limit
I want to limit query to 50 records at a time while making a GET call to Service Now. I have checked there is one parameter(sysparm_limit) by which I can limit the number of queries at a time but I want that if number of records are 10000 then it should get all the records but in 50 records per query fashion. Any idea how to achieve this.
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2016 09:49 AM
The idea of having sysparm_limit and link header is exactly to support this scenario. When you make your first call on load of page, you pass sysparm_limit =30 as query parameter.
With the response, you will get next, prev link in headers. when ever you scroll down, you make next call to get next 30 records using next and keep going
It is recommended to use ORDERBY so you don't get duplicate records because of changes in DataBase plan which might re order results causing duplicates
For eg. My initial request for 10 records looks like this
Response will have Link header
Link →
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="first",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="next",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="last"
If you see here there is link for rel=next, which gives you next 10 records. There are libraries out there which can parse this header elegantly to get proper links for next, first,last set of records.
In this case, we need to get 'rel=next' link and make subsequent request to get next 10 records
Response will have another set of headers with again next, prev link to get that set of records
Link →
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="first",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="prev",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="next",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="last"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 02:19 PM
Right way is to use REST API with sysparm_limit parameter instead of spinning up your own processor. It will give you option to go back and forth in result set using urls provided in Link header

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 09:58 PM
Hi Venkata,
Thank you for your valuable feedback. Here is the scenario.
I have a processor which is post, let's say, incidents to incidents table whenever user clicks on My incidents tab in UI interace. We have integrated Service Now with this UI interface.Now initially it should give 30 records and on scrolling down it should give next 30 records and so on. Could you please suggest how to set it up using sys_limit parameter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2016 09:49 AM
The idea of having sysparm_limit and link header is exactly to support this scenario. When you make your first call on load of page, you pass sysparm_limit =30 as query parameter.
With the response, you will get next, prev link in headers. when ever you scroll down, you make next call to get next 30 records using next and keep going
It is recommended to use ORDERBY so you don't get duplicate records because of changes in DataBase plan which might re order results causing duplicates
For eg. My initial request for 10 records looks like this
Response will have Link header
Link →
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="first",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="next",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="last"
If you see here there is link for rel=next, which gives you next 10 records. There are libraries out there which can parse this header elegantly to get proper links for next, first,last set of records.
In this case, we need to get 'rel=next' link and make subsequent request to get next 10 records
Response will have another set of headers with again next, prev link to get that set of records
Link →
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="first",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="prev",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="next",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="last"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 01:19 PM
I realize this is a post from a year ago.... but have a question about libraries to parse the header elegantly. Are the libraries referenced (below in bold)... ServiceNow platform libraries or from third party?
Response will have Link header
Link →
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="first",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="next",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="last"
If you see here there is link for rel=next, which gives you next 10 records. There are libraries out there which can parse this header elegantly to get proper links for next, first,last set of records.
In this case, we need to get 'rel=next' link and make subsequent request to get next 10 records
Response will have another set of headers with again next, prev link to get that set of records
Link →
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="first",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="prev",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="next",
<https://instance.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=ORDERBYsys_cr...>;rel="last"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 12:27 PM
Hey, Michael--were you ever able to find a good solution for parsing those link headers? I'm working on a project where I'm having to utilize those and I was wanting to see if anybody had found an easy solution.