How to fetch data in batch of 100

rule!PRO_qrtGap(
isActive: true,
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 2000)
)

for now i kept batch size 2000 .Pls let me know how to fetch first 500  , den 501 to 1000 etc... 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Given:

    p = page number - 1

    w = batch size (or width)

    Your startIndex will be: p*w+1

    p needs to be 0 based to get the arithmetic to work, which is why you need to subtract 1.  

    Remember to do bounds checking in your buttons, so you don't end up at page number -1, for instance.

    You will also likely have to make an allowance for the last page. 

    The last page will start at: if(mod(totalCount, w) = 0, totalCount-w+1, totalCount - mod(totalCount, w)+1), and it will return if(mod(totalCount, w) = 0, w, mod(totalCount, w)) entries.

    So, just don't assume that you can index a full page width, unless you have verified that you are NOT on the last page.

    Edit: Had to add the ifs.

Reply
  • 0
    Certified Lead Developer

    Given:

    p = page number - 1

    w = batch size (or width)

    Your startIndex will be: p*w+1

    p needs to be 0 based to get the arithmetic to work, which is why you need to subtract 1.  

    Remember to do bounds checking in your buttons, so you don't end up at page number -1, for instance.

    You will also likely have to make an allowance for the last page. 

    The last page will start at: if(mod(totalCount, w) = 0, totalCount-w+1, totalCount - mod(totalCount, w)+1), and it will return if(mod(totalCount, w) = 0, w, mod(totalCount, w)) entries.

    So, just don't assume that you can index a full page width, unless you have verified that you are NOT on the last page.

    Edit: Had to add the ifs.

Children
No Data