3

I have to paginate total of 4000-5000 records with 20 records per page. I am using a wrapper class type List. This list would be displayed on a pageblocktable.

I CANT use OFFSET because offset has a limit of paginating 2000 records on total.

StandardsetController has limit of 10000 records. However, using standardsetcontroller, we CANT persist the value of checkbox when we click "NEXT" page.

I am planning to use Iterator for this job. Can anyone tell me what is the limit of records i can paginate when i implement Iterator?

  • 1
    are you saying you are displaying 4K-5K records at a time? – Ratan Paul May 4 '16 at 12:08
  • nope a total of 4K-5K records. PageSize would be 15, i.e, 15 records per page – vishal May 4 '16 at 12:10
  • Yes .. so go with OFFSET approach because offset limit 2000 means If you are displaying more than 2000 records at a time in VF page then only this issue occurs – Ratan Paul May 4 '16 at 12:11
  • Ratan thanks for the reply. I CANT use OFFSET because the moment you click on the "Last Page" button, salesforce will give you exception saying more than 2000 Records are queried using OFFSET. – vishal May 4 '16 at 12:13
  • so when you use offset use limit also in SOQL so it will give you only few records .. limit can 15, 25 etc records – Ratan Paul May 4 '16 at 12:23
1

One solution would be to query and hold ALL records in a List in your controller. Then from this list take a range of records and populate them into your wrapper for displaying on the page. This way all checked records would be saved in your controller only wrapper.

The downside to this would be you'd have to keep track of everything in the controller.

0

EDIT:

Well my previous answer only works for limited number of records.So i searched it a little and i found this nice answer by sfdcfox.

check this out: Workaround for Offset 2000 limit on SOQL Query

Previous answer:

As Ratan has already pointed out...You have to use limit and offset together in the query.

For eg.

SELECT Name
FROM Merchandise__c
WHERE Price__c > 5.0
ORDER BY Name
LIMIT 100
OFFSET 10

Refer this for more info: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_offset.htm

  • I am not getting point of the answer. Topic starter asking about how to use offset more than 2000. No idea how this answer can help – kurunve May 4 '16 at 12:46
  • In the comments Vishal has mentioned that on the page at a time he is showing only 15 records. That way he will not cross the limit of 2000 records. – Mr.Frodo May 4 '16 at 12:52
  • that still not clear about how to get records from 3000 till 3015 for example. – kurunve May 4 '16 at 12:56
  • Yes I got your point. Maybe I will come up with something better – Mr.Frodo May 4 '16 at 12:58
  • @Mr.Frodo Thanks Frodo for your answer. However, my question is how many records we can paginate using iterators? i am aware of using offset and its limitation. – vishal May 5 '16 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.