I am uploading a csv using apex programming to upload data to my custom object. I am getting this error while uploading csv file. Some the same is uploading correctly. Can one tell how to resolve this. I tried a lot but i couldn't resolve this.
Error: List index out of bounds: 5 Error is in expression '{!ReadFile}' in page
for (Integer i=1;i < filelines.size();i++)
{
String[] inputconvalues = new String[]{};
inputconvalues = filelines[i].split(',');
Contact con = new Contact();
for(Account a: accstoupload)
{
con.AccountId =accstoupload[i-1].id;
}
if(con.AccountId!= null)
{
con.Lastname = inputconvalues[36];
con.Email = inputconvalues[37];
con.Phone = inputconvalues[38];
contoupload.add(con);
}
}
try
{
insert contoupload;
}
catch (Exception e1)
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.INFO,'Account Name associate with this Contact already exist ');
ApexPages.addMessage(errormsg);
}
return null;
accstoupload
. How are we supposed to help when you don't give a clear picture of your code.inputconvalues = filelines[i].split(',');
shouldn't it beinputconvalues = filelines[i-1].split(',');