I am facing this issue while uploading the data using CSV file on VF page with above 1000 Records.
Can any one please help me to overcome this issue.
Here is my code :
public class ItemsUploaderclass
{
public String[] filelines {get;set;}
public List<Items__c> uploadlist;
public ItemsUploaderclass(ApexPages.StandardController controller) {
filelines = new String[]{};
uploadlist = new List<Items__c>();
}
// Method to read csv file
public Pagereference ReadFile()
{
String[] errors = new List<String>();
map<String,String> nameToCode = new map<String,String>();
boolean check = false;
for (Integer i=1;i<filelines.size();i++){
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');
isoCodeRep = false;
if(inputvalues.size() == 1) {
continue;
}
Items__c item = new Items__c();
if(inputvalues[0] != ''){ item.Item_Number__c = inputvalues[0];
}
if(inputvalues[1] != '') {item.codeABC__c = inputvalues[1];}
if(inputvalues[2] != '') {item.Code_XYZ__c = inputvalues[2];}
if(inputvalues[3] != '') { item.Unit__c = inputvalues[3]; }
if(inputvalues[4] != '') { item.price__C = inputvalues[4]; }
if((item.Name!= null && item.Quantity__c != null && item.UnitPrice__c != null && item.CurrencyIsoCode != null && item.Opportunity__c != null && item.Name != 'N/A' && (!isoCodeRep) ))
{
uploadlist.add(item);
}
else
ApexPages.addmessage(new ApexPages.Message(ApexPages.severity.FATAL,'Error uploading the items with number :'+ item.Item_Number__c ));
}
if (ApexPages.hasMessages(ApexPages.Severity.FATAL)){
ApexPages.addmessage(new ApexPages.Message(ApexPages.severity.WARNING,'Upload Failed'));
return null;
}
else
try{
insert uploadlist;
ApexPages.addmessage(new ApexPages.Message(ApexPages.severity.INFO,'File Uploaded Successfully'));
}catch (Exception e){
System.debug('Error when inserting item scrubs:' + e);
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'Error uploading the new item:' + e);
return null;
}
}
else{ //Display error message when no CSV file is chosen
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,'Please choose a valid CSV file'));
}
return null;
}
public List<Items__c> getuploadeditem()
{
if (uploadlist!= NULL)
if (uploadlist.size() > 0)
return uploadlist;
else
return null;
else
return null;
}
}
VF page :
<apex:pageblocktable value="{!uploadeditem}" var="item" rendered="{!NOT(ISNULL(uploadeditem))}">
<apex:column headerValue="Number">
<apex:outputText value="{!item.Item_Number__c}"/>
</apex:column>
<apex:column headerValue="Unit">
<apex:outputField value="{!item.Unit__c}"/>
</apex:column>
<apex:column headerValue="Price">
<apex:outputField value="{!item.price__C}"/>
</apex:column>
</apex:pageblocktable>
Map<String, String>with 8000 records in it bound to apageBlockTableand it rendered without error. This behavior is "new", the VF collection limit has been 1000 for as long as I can remember. Map or List, both respected the limit. How long have you been aware of this exception to the limit? – Mark Pond Aug 01 '16 at 19:03keyset()is in no particular order regardless of key value type – cropredy Aug 02 '16 at 14:59