I have a VF page that uses a custom controller and I get the following error:
Visualforce Error: Collection size 4,820 exceeds maximum size of 1,000.
The controller was working properly, but I added an IF/ELSE clause (lines 18 - 36). I assume that's causing the issue, but I'm not sure what I need to do to fix. Can anyone help?
Controller
public class VF_SFController{
public List<E_S_F__c> ESF {get; set;}
private final Opportunity opp;
public VF_SFController(ApexPages.StandardController myController){
ESF = new List<E_S_F__c>();
if (!Test.isRunningTest())
{
myController.addFields(new List<String>{'Id', 'website_s__c', 'MT_Site_URLs__c', 'OwnerId', 'Owner.Phone', 'RecordType.Name'});
}
opp=(Opportunity)myController.getrecord();
}
public E_S_F__c ESF2 = new E_S_F__c();
public void EngSF(){
IF(opp.RecordType.Name == 'Eng Mid'){
ESF2.Opportunity__c = opp.Id;
ESF2.Websites__c = opp.MT_Site_URLs__c;
IF(opp.MT_Site_URLs__c != null){
ESF2.Website_Complete__c = TRUE;
}
ESF2.Sales_Representative__c = opp.OwnerId;
Opportunity o = [SELECT (SELECT Id, contactId
FROM OpportunityContactRoles
WHERE isPrimary = TRUE)
FROM Opportunity
WHERE id = :opp.id];
ESF2.Partner_Contact__c = o.opportunityContactRoles.size() != 0
? o.opportunityContactRoles[0].contactId
: null;
}
Else{
ESF2.Opportunity__c = opp.Id;
ESF2.Websites__c = opp.website_s__c;
IF(opp.website_s__c != null){
ESF2.Website_Complete__c = TRUE;
}
ESF2.Sales_Representative__c = opp.OwnerId;
Opportunity o = [SELECT (SELECT Id, contactId
FROM OpportunityContactRoles
WHERE role = 'Signatory')
FROM Opportunity
WHERE id = :opp.id];
ESF2.Partner_Contact__c = o.opportunityContactRoles.size() != 0
? o.opportunityContactRoles[0].contactId
: null;
IF(opp.Region__c.startsWith('AA')){
Opportunity o2 = [SELECT (SELECT Id, contactId
FROM OpportunityContactRoles
WHERE role = 'Billing')
FROM Opportunity
WHERE id = :opp.id];
ESF2.Billing_Contact__c = o2.opportunityContactRoles.size() != 0
? o2.opportunityContactRoles[0].contactId
: null;
}
}
ESF.add(ESF2);
}
public PageReference save() {
insert ESF;
PageReference RetPage = new PageReference('/apex/VF_SF_View?id=' + ESF[0].id);
RetPage.setRedirect(true);
return RetPage;
}
}
OpportunityContactRoles
on the page?<apex:repeat>
,<apex:pageBlockTable>
,<apex:dataTable>
, etc would be considered looping through the results.