Set offset for GlideRecord query

peter_repan
Tera Guru

Hi all,

I would like to create a custom table with pagination. I need to fill table with GlideRecord query.

I know that it is possible to use setLimit(int) function to get only requested number of rows, but it is somehow possible to set offset of this records, to be able to use pagination for fetching second, third... set of items ?

Example:

var gr = new GlideRecord('incident');

gr.skip(30); ----> how to do something like this ?

gr.setLimit(10);

gr.query();

1, 2, 3, 4, 5

---> will return fourth set of 10 records

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi Peter,



I think this is what you are looking for



gr.chooseWindow(10, 20);       // this will give you 10 records, starting form the 11th to 20th.



Real more here in depth


GlideRecord Glimmerings: Windows...


-Anurag

View solution in original post

16 REPLIES 16

bashashaik
Giga Contributor

Hi Peter


i don't think we have anything like these. For giving next record we use next() function on Glide Record object.. if you want it to start from fourth record.. i guess you need to call next() that many times.. that i will map that record.


Hi Basha,



but I'm afraid that when I have 50 000 records (with paging 100) and want to display records from 40 000 to 40 100, if I do .next() 40 000 times, it will load all 40 000 records. I want to save some performance and load only requested 100 records. I'm looking for the best possible way, maybe you are right that I have no choice instead of use .next()


Yep.. your correct.. Lets c if any have better way to achieve that


Hi Peter,



                  Clarify the below query.


As per you if 40,000 to 40,100 records are available how would you you need to send only 100 particular users..