2

I'm creating a Search page so user can search all of the objects by Super Customers and I have ran into a snag. Originally I set up my search like this .

Edit -- I Don't want to Pagination that many records, It looks like on load the entire Oppty Object is getting queried THEN once the Search is done it filters it.

    public List<Case> setOppCon (Set<Id> accountIds){
        return[
        SELECT Name,OwnerId,StageName,RecordTypeId,Design_Region__c,Design_Territory__c,Potential_Value1__c,
                            LastModifiedDate,Probability 
                         FROM Opportunity WHERE Account__c IN: accountIds];
    }

I was not thinking of pagination when I built it , so in order to allow pagination I switched it so I can now use StandSetControllers as such

public ApexPages.StandardSetController setOppCon {
    get {
        if(setOppCon == null) {
            setOppCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                [SELECT Name,OwnerId,StageName,RecordTypeId,Design_Region__c,Design_Territory__c,Potential_Value1__c,
                            LastModifiedDate,Probability 
                         FROM Opportunity]));
        }
        return setOppCon;
    }
    set;
}      
     public List<Opportunity> getOpps(Set<Id> accountIds) {
             setOppCon.setPageSize(5);
            return (List<Opportunity>) setOppCon.getRecords();
     }

But now the issue that I am having is that I am getting an error Too many query locator rows: 10001, and I believe that is happening because now I am querying every single record at load and filtering rather than querying with the filter in place.

Pagination I thought was suppose to fix that, but I am having no luck. I'm somewhat confident I did the class correct, I am unsure about the VF Page.

</apex:pageBlock>
    <apex:pageBlock title="Opportunities">
    <apex:pageblockTable value="{!optyList}" var="opty">
    <apex:column headerValue="Opportunity Name"><apex:outputLink value="/{!opty.Id}">{!opty.Name}</apex:outputLink></apex:column>
    <apex:column value="{!opty.OwnerId}"/>
    <apex:column value="{!opty.StageName}"/>
    <apex:column value="{!opty.RecordTypeId}"/>
    <apex:column value="{!opty.Design_Region__c}"/>
    <apex:column value="{!opty.Design_Territory__c}"/>
    <apex:column value="{!opty.Potential_Value1__c}"/>
    <apex:column value="{!opty.LastModifiedDate}"/>
    <apex:column value="{!opty.Probability}"/>
    <apex:column value="{!opty.StageName}"/>                  
    </apex:pageblockTable>
         <apex:commandButton rendered="{!setOppCon.hasPrevious}" value="First" action="{!setOppCon.first}"/>
          <apex:commandButton rendered="{!setOppCon.hasPrevious}" value="Previous" action="{!setOppCon.previous}"/>
          <apex:outputText rendered="{!(setOppCon.pageNumber * setOppCon.pageSize) < setOppCon.ResultSize}" value="{!setOppCon.pageNumber * setOppCon.pageSize} Of {!setOppCon.ResultSize}"></apex:outputText>
          <apex:outputText rendered="{!(setOppCon.pageNumber * setOppCon.pageSize) >= setOppCon.ResultSize}" value="{!setOppCon.ResultSize} Of {!setOppCon.ResultSize}"></apex:outputText>            
          <apex:commandButton rendered="{!setOppCon.hasNext}" value="Next" action="{!setOppCon.next}"/>            
          <apex:commandButton rendered="{!setOppCon.hasNext}" value="Last" action="{!setOppCon.last}"/>
  </apex:pageBlock>
3
  • 1
    Seems like pagination only works for up to 10k records based on Peter's response here: salesforce.stackexchange.com/questions/42702/…
    – Scott
    Dec 10 '14 at 5:53
  • @Scott I just don't know where to start if I were to filter there, my search is looking through 5 different objects.
    – EricSSH
    Dec 10 '14 at 18:35
  • @Scott and to Add onto your comment, I don't want to pagination that many records
    – EricSSH
    Dec 10 '14 at 19:35

Your Answer

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

Browse other questions tagged or ask your own question.