function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rakesh ChattyRakesh Chatty 

show more than 10000 records in visual force

Hi, Im trying to display more than 10000 records i'm facing an error.

Visualforce Error
Help for this Page
Collection size 10,358 exceeds maximum size of 10,000.

Please find the code and suggest me.

VF Page:
<apex:page controller="Display10000" readOnly="true" >
    <apex:pageBlock title="{!size} records retrived">
        <apex:pageBlockTable value="{!accList}" var="a">
            <apex:column value="{!a.name}"  />
            <apex:column value="{!a.phone}"  />
            <apex:column value="{!a.AccountNumber}"  />
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 

Apex:

public class Display10000 {
    public  List<Account> accList {get; set;}
    public Integer size{get;set;}
   
    //constructor
    public Display10000(){
       accList = [Select Name,AccountNumber,Phone from Account]; 
       size = accList.size();
    }
}

please help me in retriving more than 10k records.

 

Thanks in advance.

 

AnudeepAnudeep (Salesforce Developers) 
Hi Rakesh - You are running into a hard limit. As per the documentation, the limit to iterate over a collection on a visualforce page is 10,000 when the readOnly attribute is set to true. You will have to implement pagination to work on records more than 10,000.

I recommend taking a look at this post

Let me know if this helps

Thanks, 
Anudeep

 
Rakesh ChattyRakesh Chatty
Hi @Anudeep,

with out using pagination is there is any other way to show more than 10k records with in same page.

Thanks,
Rakesh
Abhishek Sharma 36Abhishek Sharma 36
Hi Rakesh,

Please use transient variable
public  transient List<Account> accList {get; set;}
public transient Integer size{get;set;}

It will work. If not then you have to use pagination where offset will come into account.
Rakesh ChattyRakesh Chatty
Hi @Abhishek,

Thank you for suggesting transient, But even this not working. Any other ideas apart from pagination.

Thanks,
Rakesh