[SalesForce] How to query more than 50k records and display in visualforce page

I have a one vf page which displays list of all records in Account object using controller and I am using pagination to show all records it is working fine.

But my Account records are crossed 50k records so now I am getting 50001 error.

I also tried below things but still it's not working.

  1. I tried the readonly="true" attribute in the` tag
  2. I tried database.query()

I saw some of the post we can use batch apex but my doubt is how can we link page and batchapex.

Thanks in Advance.

Best Answer

Setting the Readonly attribute at the page level should remove the 50,000 record limit.

<apex;page standardcontroller="Account" readOnly="true">

this should open the limit to 1 million records. If you are still getting the 50001 error, you may not be setting the attribute correctly. Your other option would be to leverage the SOQL query OFFSET to create your own pagination subqueries. SOQL OFFSET

Related Topic