How to apply pagination in the scripted rest api Resource for GET call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 05:24 AM
Hello All,
I have a custom table X and it has 10 lakh records and the requirement is to create an API to pull all the records with field, value information in JSON format with fieldname as Key and field value as Value.
I have created a Scripted Rest API Resource with HTTP method as GET and written GlideRecord syntax on this table X
eg:
var arr = [];
var gr = new Gliderecord('tablex');
gr.query();
while(gr.next()){
var respData = {};
respData = {field1 : fieldvalue1,
field2 : fieldvalue2,
field3 : fieldvalue3
};
arr.push(respData)
}
response.setBody(arr);
So, I tested this Scripted REST API and I am not able to get the response and transaction failing due to records count is huge. So, I wanted to split the records retrieval in Chunks say 10000 for the first call and next 10000 record in 2nd call and get the records.
How to apply pagination in scripted rest api resource. Please assist.