- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2016 05:13 AM
Hi everyone,
I've created a REST API Script that allows me to get records from my incident table. However, we would like to use pagination so that if we have a multitude of records, we are able to page through and not have a massive amount of data in one call. From what I've been finding, using a combination of sysparm_limit and sysparm_offset is the best way to go to have something that is similar to pagination. Since I'm using a script instead of the REST API Explorer to create my objects, I haven't been able to find anything that allows to use something similar to sysparm_offset. The script I have set up creates the JSON object since I have to do calls into multiple tables to get certain values. To substitute sysparm_limit, I found that I can use gr.setLimit(10000) as an example since that's part of the glide record functionality. There was a previous post that had said about using gr.Window(10, 20) or something along those lines, I'm not 100% sure. I know that I can get sysparm_offset as a queryParam, but what to do with it from there, I'm not sure. If someone could point me in the right direction, that would be great! Thanks!
Eric
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2016 05:17 AM
Hi Eric,
I couldn't find it in the documentation, but other community articles seem to point to this solution.
gr.chooseWindow(10, 20); // this will give you 10 records, starting form the 11th to 20th.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2016 05:17 AM
Hi Eric,
I couldn't find it in the documentation, but other community articles seem to point to this solution.
gr.chooseWindow(10, 20); // this will give you 10 records, starting form the 11th to 20th.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2016 05:20 AM
Hey Chuck,
Thanks for getting back to me so quick! I thought that sounded familiar, and I think ultimately that's what I'll have to use for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2018 11:14 AM
HI Eric,
If you were achieve pagination through scripted api, can you please share the complete solution as i have a similar requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2018 11:28 AM
Hi ibhavya,
What we did was have an outside program continously call the Scripted REST API until no records are found. We store this values as variables in the beginning.
var offset = request.queryParams.offset,
limit = request.queryParams.limit,
record_limit = 10000,
From there, it will do an if statement to see if there is an offset stored from our outside procedure
if (offset != '' && offset != null) {
endRecordAmount = +offset + +limit;
gr.chooseWindow(offset, endRecordAmount);
}
Hopefully this helps you out!
Thanks,
Eric