2

I created this class that is requesting large amount of data, I was getting this error:Collection size 1,156 exceeds maximum size of 1,000. And then I found an approach to fix this error, the code is below using an wrapper class that handles the limit. It works in the sandbox, but I don't have a lot of data there. So when I tested it in production I am getting this error: Response size exceeded 15MB organization limit. I couldn't find much help about this error. I don't know if there is something wrong in the code or there is a different approach. I will appreciate any help!

VF Page code:

  <apex:pageBlock >
        <apex:repeat value="{!thousandBlocks}" var="block">

           <apex:pageBlockTable value="{!block.zeroInventory}" var="p" id="mid">

           <apex:column value="{!p.Account__r.Name}"/>
           <apex:column value="{!p.Name}"/>
           <apex:column value="{!p.Product_Name__c}"/>
           <apex:column value="{!p.Virtual_Amz__c}"/>
           <apex:column value="{!p.Total_Inventory2__c}"/>
           <apex:column value="{!p.Days_of_Inventory__c}"/>
           <apex:column value="{!p.X24_Hr_Units__c}"/>
           <apex:column value="{!p.X7_Day_Units__c}"/>
           <apex:column value="{!p.X30_Day_Units__c}"/>
           <apex:column value="{!p.X24_Hr_Units__c}"/>
           <apex:column headerValue="Go To"> <span class="label label-success"><a href="https://na2.salesforce.com/{!p.id}" target="_blank" style="color:white;">Go to Product</a></span></apex:column>

        </apex:pageBlockTable>
       </apex:repeat>
    </apex:pageBlock>

Class code:

  public class dashBoardPOIssues {
     private limitWrapper[] thousandBlocks = new limitWrapper[]{};
     private final integer listLimit;  

     public dashBoardPOIssues(){

        //for zero inventory
        listLimit = 950;
     }

      //for zero inventory
 public limitWrapper[] getthousandBlocks()
 {
    thousandBlocks = new limitWrapper[]{};

    integer counter = 0;
    integer loopCount = 0;
    NRProducts__c[] tmpcase = new NRProducts__c[]{};

    for(NRProducts__c c:[SELECT id, Name, Account__r.Name, ASIN__c,CreatedDate,Product_Name__c,Virtual_Amz__c,Total_Inventory2__c,Days_of_Inventory__c,X24_Hr_Units__c,X7_Day_Units__c,X30_Day_Units__c   FROM NRProducts__c  WHERE  Total_Inventory2__c = 0  AND Buyer_lookup__c =:UserInfo.getUserId()])
    {
        if(counter < listLimit)
        {
            tmpcase.add(c);
            counter++;
        }
        else
        {
            loopCount++;
            thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
            tmpcase = new NRProducts__c[]{};
            tmpcase.add(c);
            counter = 0;
        }            
    }

    if(thousandBlocks.size() == 0)
    {
        loopCount++;
        thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
    }

    return thousandBlocks;
   }

     public class limitWrapper
    {
      public NRProducts__c [] zeroinventory {get;set;}
      public integer blockNumber {get;set;}
      public limitWrapper(NRProducts__c[] accs, integer i)
    {
        zeroinventory = accs;
        blockNumber = i;
    }

    }
  }
5
  • 3
    Try removing a few columns in your table. With such a large number of records, your view state could potentially be too large. If that makes the error go away, then that is likely your issue.
    – dphil
    Jun 16, 2014 at 18:46
  • I will do so right now!
    – Carlos
    Jun 16, 2014 at 18:48
  • dphil,you were right! Thank you so much... I really appreciate it!
    – Carlos
    Jun 16, 2014 at 19:01
  • It was actually the response size, though, not view state size.
    – sfdcfox
    Jun 16, 2014 at 19:57
  • yes now that I am working with larger data i am facing the governor limits. luckily there are nice people in this site to help.
    – Carlos
    Jun 16, 2014 at 21:25

0

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.