0

We are using the ApexPages.StandardSetController to display a list of results in a visualforce page. But as soon as we select more than 20 records, the number of results returned by the method isn't correct. This is before any custom code gets a chance to run.

First user select records that they want the code to process, and then click the custom button we created. At this point, the code is suppose to get all the record that is checked by using ApexPages.StandardSetController.getSelected(), which will return list of SObject. However, the size of the list returned by the method does not match the amount we selected whenever we select 20+ records, and it seems like a portion of the record is missing.

Whenever we select 50, the value passed in is 35, if we select 45, it passes in 32, if we select 200, it gives 96 back. No mater what record I select, as long as the number selected is 50, it always return 35. Same for 45, and 200 records. The only cases that it works is if the number selected is smaller than 22. For 22 itself, it return 21 records.

Anyone know how to fix this issue? Or is it saleforce issue?

Here's my code

public with sharing class FS_ProformaTemplate {
public static String ID_PARAM = 'id';
public ApexPages.StandardSetController setController;
public Id lastSalesOrderId {get;set;}

private static final String SALES_ORDER_SHORT_URL = 'FS_Short_URL';
private List<SalesOrderAndURL> relevantSalesOrders = new List<SalesOrderAndURL>();

public FS_ProformaTemplate(ApexPages.StandardSetController setController) {
    this.setController = setController;
    System.debug('setcontroller size: ' + setController.getSelected().size());
}

Update:

I found the issue on the visualforce page. Whenever I was trying to use

<apex:pageBlockTable>

The page number is showing differently. If I disable the whole tag, it works fine. Any ideas?

Here's the VF code

<apex:pageBlockSection >

            <apex:pageBlockTable value="{!currSalesOrder.salesOrder.OrderApi__Sales_Order_Lines__r}" var="solItem">
                <apex:column >
                    <apex:outputPanel rendered="{!solItem.OrderApi__Item__r.name='Member' || solItem.OrderApi__Item__r.name='Premium Subscriber'}">
                        <apex:outputLabel >Dues are based on the {!$Label.FS_DuesBasedOnYear} opening day enrollment numbers:&nbsp;&nbsp;</apex:outputLabel>
                        <apex:outputField value="{!solItem.FS_Total_PreK__c}"/>&nbsp;Total PreK and&nbsp;
                        <apex:outputField value="{!solItem.FS_Total_K13__c}"/>&nbsp;Total K-13 students.<br/><br/>
                    </apex:outputPanel>
                </apex:column>
            </apex:pageBlockTable>

</apex:pageBlockSection>
  • so, does the code that displays the items to select use without sharing and the code that processes the selected items use with sharing? – cropredy Oct 18 '19 at 21:29
  • @cropredy I didn't declare it, but I explicitly put with sharing and it still behave the same way – David Oct 21 '19 at 13:26
  • David. There's not enough info here. Post VF page and also whatever code populates the VF page with data. – cropredy Oct 21 '19 at 14:45
  • @cropredy I made an update on the issue. It seems like the tag is causing the problem. Any ideas? – David Oct 21 '19 at 15:33
  • @cropredy found the issue, I was getting the Sales order line inside sales order, but some of the sales order might not have sales order line, that's why it's showing the number incorrect. – David Oct 21 '19 at 15:36

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.