Need to understand "sysparm_limit and sysparm_offset" in real time

Nik Amy
Tera Contributor

Hey Guys,

Can any one clearly explain whats the difference or usage of "sysparm_limit" and "sysparm_offset".

I need a real time usage of those 2.

Have read about this community but wasnt clear.

 

Consider this:

For below particular date, there are more than 5k records. so in below query, what are the different ways I can make use of those 2 fields.

https://dev12345.service-now.com/api/now/table/incident?sysparm_fields=number,state,priority&sysparm_limit=10&sysparm_offset=0&sysparm_query=opened_at%3Ejavascript:gs.dateGenerate(%272018-08-01%27,%2700:00:00%27)%5Eopened_at%3Cjavascript:gs.dateGenerate(%272018-09-01%27,%2700:00:00%27)

 

Thanks much in Advance 🙂

 

Nik Amy

1 ACCEPTED SOLUTION

The third party should send the sysparm_limit and sysparm_offset.

if your table doesn't have too many columns, 10000 record per transaction should be good.

 

So the first one should be sysparam_limit=10000&sysparm_offset=0

next one should be sysparam_limit=10000&sysparm_offset=10000

sysparam_limit=10000&sysparm_offset=20000

 

They can identify the Last transaction they need to send using the Link in the Header Response 

 
 
<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"

Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

If you have 5k records, you should probably use sysparm_limit. This will limit the number of records sent to the third party from ServiceNow.

 

If you don't set a limit, it can impact performance and if the record size is huge, sometimes it mayn't send all the records .

So it is better to add the sysparm_limit. And then in the header you should receive the link to get the next set of records.

 

Now if you note the response, In the link, it send the response back with the offset.

So basically I am getting the first set of 10 (0 - 9) records in below example. Now to next set of record should start from 10 to 19. So I would set the offset to 10. So that I get the next set of record which is record 10 to 19. Then if I set offset to 20, it will give me the result of 20 to 29. So basically you are getting response in chunks or pages. Thats called pagination


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

so basically who will set the offset and to what value.

 

say If the user at third party system wants to pull all records "created on this year" in servicenow (say there would be some 30k records in this year), what should be the query he should use so that all 30 k records he will get.

 

NIK

The third party should send the sysparm_limit and sysparm_offset.

if your table doesn't have too many columns, 10000 record per transaction should be good.

 

So the first one should be sysparam_limit=10000&sysparm_offset=0

next one should be sysparam_limit=10000&sysparm_offset=10000

sysparam_limit=10000&sysparm_offset=20000

 

They can identify the Last transaction they need to send using the Link in the Header Response 

 
 
<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"

Please mark this response as correct or helpful if it assisted you with your question.

Thanks Sanjiv!