I have an issue here, where i need to populate geography__c list on vf page. I am getting the below error . I can't use Limit 1000 as i need to display all the records in vf page. Is there any workaround for this issue.
Collection size 33,046 exceeds maximum size of 1,000
Vf Page –
<apex:actionregion >
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.RFP__c.Fields.Country__c.Label}" style="width:87%; float:right;height:0px;font-weight:bold;font-family:Arial;font-size:11px;color:#2F4F4F;"/>
<apex:outputPanel id="countries" layout="block" styleClass="requiredInput" style="width:82%; float:right;">
<apex:outputPanel id="countr" layout="block" styleClass="requiredBlock"/>
<apex:selectList value="{!discountScheduleID}" size="1" styleClass=" chzn-select" >
<apex:actionSupport event="onchange" action="{!FindAllName}" rerender="geographies" oncomplete="renderChosen()" />
<apex:selectOptions value="{!dept}" />
</apex:selectList>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.RFP__c.Fields.Type__c.Label}" style="width:87%; float:right;height:5px;font-weight:bold;font-family:Arial;font-size:11px;color:#2F4F4F;"/>
<apex:outputPanel id="type" layout="block" styleClass="requiredInput" style="width:82%; float:right;">
<apex:outputPanel id="type1" layout="block" styleClass="requiredBlock"/>
<apex:selectList value="{!TypeID}" size="1" styleClass=" chzn-select" >
<apex:selectOptions value="{!Type}" />
</apex:selectList>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.RFP__c.Fields.Geography__c.Label}" style="width:87%; float:right;height:8px;font-weight:bold;font-family:Arial;font-size:11px;color:#2F4F4F;"/>
<apex:outputPanel id="geographies" layout="block" styleClass="requiredInput" style="width:82%; float:right;">
<apex:outputPanel id="geos" layout="block" styleClass="requiredBlock"/>
<apex:selectList value="{!selectedGeographyIds }" multiselect="true" id="selectedGeographies" styleClass="fullWidth chzn-select" >
<apex:selectOptions value="{!AllName}" id="movieTextBox"></apex:selectOptions>
</apex:selectList>
<apex:outputPanel layout="block" styleClass="errorMsg" >
<apex:outputText value="{!errorMap['selectedGeographies']}"
escape="false" rendered="{!errorMap['selectedGeographies'] != ''}" />
</apex:outputPanel>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:actionregion>
Apex Class –
public void FindAllName()
{
system.debug('@@@@@@ Entered');
AllName= new List<SelectOption>();
AllName= getName();
}
public List<ID> holdData(){
List<ID> rfpGeographiesToInsert = new List<ID>();
for (ID selectedGeographyId : selectedGeographyIds) {
rfpGeographiesToInsert.add(selectedGeographyId);
system.debug('#############' + rfpGeographiesToInsert);
}
return rfpGeographiesToInsert;
}
public List<SelectOption> getName()
{
Set<String> sProj = new Set<String>();
List<Geography__c > tohold = new List<Geography__c >();
List<ID> lst = new List<ID>();
lst = holdData();
system.debug('@@@@@@' + lst);
if(discountScheduleID != null )
{
system.debug('1111111');
if(lst.size()==0)
{
system.debug('2222222');
for(Geography__c Proj :[select Id, Canonical_Name__c, Type__c from Geography__c where status__c = 'active' AND Country__c =: discountScheduleID AND Type__c =: TypeID order by Canonical_Name__c] )
{
system.debug('3333333');
options.add(new SelectOption(Proj.ID,Proj.Canonical_Name__c));
//strGeographix += Proj.Canonical_Name__c + ', ';
//errorMap.put('selectedGeographies',Proj.Canonical_Name__c);
}
}
else
{options.clear();
for(Geography__c Proj :[select Id, Canonical_Name__c, Type__c from Geography__c where status__c = 'active' AND Country__c =: discountScheduleID and Id not in:lst order by Canonical_Name__c] )
{
system.debug('4444444');
options.add(new SelectOption(Proj.ID,Proj.Canonical_Name__c));
//strGeographix += Proj.Canonical_Name__c + ', ';
// errorMap.put('selectedGeographies',Proj.Canonical_Name__c);
}
for(Geography__c Proj1 :[select Id, Canonical_Name__c, Type__c from Geography__c where status__c = 'active' AND Id in:lst order by Canonical_Name__c])
{
options.add(new SelectOption(Proj1.ID,Proj1.Canonical_Name__c));
}
}
}
return options;
}
}
Regards
Best Answer
You are trying to display 33,046 values in a picklist/drop down list I think. I don't think that is a very wise idea even from a usability point of view.
Either try to break the picklist up by geographies, or use a search like feature to fetch the required values.