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
Rajesh SFDCRajesh SFDC 

how to solve this error:Collection size 1,247 exceeds maximum size of 1,000. in visualforce page?

how to solve this error:Collection size 1,247 exceeds maximum size of 1,000. here my requirments i want to display 3000 reocords in visualforce page but i am getting an error,, plz help me frds

<apex:page controller="wrapperController" sidebar="false" >
  
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>

            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">

                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <!--apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/-->
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                  
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>

                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                  
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>

            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>

</apex:page>
====================================================================================================controller =========================

public class wrapperController{

    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
    string currentrecordid= ApexPages.currentPage().getParameters().get('id');

    public wrapperController()
    {
        if(wrapAccountList == null)
        {
            wrapAccountList = new List<wrapAccount>();
            LIST<Account> ac=new list<Account>();
            map<string,string> resultmap=new map<string,string>();
           
           // integer countrecord=[select count() from account  ];
            system.debug('^^^^^^^^countrecord+countrecord');
            ac=[select Id, Name, Website, Phone from Account ];
            for(Account a: ac )
            {
               
                wrapAccountList.add(new wrapAccount(a));
               
                system.debug('$$$$$$$$$$$$$$$$4'+wrapaccountlist);
            }
        }
    }

    public void processSelected()
    {
    selectedAccounts = new List<Account>();

        for(wrapAccount wrapAccountObj : wrapAccountList)
        {
          system.debug('@@@@@@@@@@@@@@@222'+wrapAccountObj);
            if(wrapAccountObj.selected == true)
            {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }

  
    public class wrapAccount
    {
        public Account acc {get; set;}
  
        public Boolean selected {get; set;}

        public wrapAccount(Account a)
        {
           system.debug('##########'+a);
            acc = a;
            system.debug('*************acc'+acc);
            selected = false;
            system.debug('selectd'+selected);
        }
    }
}
=======================================================================================================================================================
Chidambar ReddyChidambar Reddy
I think the following link may help you

http://kuldeeptyagi.blogspot.in/
dev_sfdc1dev_sfdc1
Hi,
Try to use like this if you need to view only records

<apex:page controller="sample" readOnly="true">
  
</apex:page>

It will bring upto 1 million records but we can't able to do some process of insert,update.
You can try readonly attribute before pagination code..

Thank You
Satish_SFDCSatish_SFDC
There are workarounds as mentioned by chidambaram above.
However, larger sizes of list would have a negative effect on the VF page as it will take a lot of time to load the page.

Regards,
Satish Kumar
sunny522sunny522
Hi Rajesh,
       Use readonly="true" attribute of <apex:page> tag or else use pagination to display records in visualforce page.
Please let me know if u need further help.