You need to sign in to do that
Don't have an account?
Julien Camp
List index out of bounds - 0: Error - how to fix?
Hello,
We are receiving an error in relation to a recently deployed Apex Class.
Here's the error:
"caused by: System.ListException: List index out of bounds: 0
Class.EditClientComplianceCheckList_Controller.<init>: line 25, column 1"
And here is line 25 (and a few subsequent lines):
system.debug('ClientComplianceDocuments_List=='+ClientComplianceDocuments_List[0].Id+' name =='+ClientComplianceDocuments_List[0].Name);
ClientComplianceDocId_ComplianceDoc_Map = new Map<Id,Compliance_Document__c>();
ComplianceDocuments_NewlyAdded_Map = new Map<Compliance_Document__c,Boolean>();
Anyone have any insight?
Thanks!
Julien
We are receiving an error in relation to a recently deployed Apex Class.
Here's the error:
"caused by: System.ListException: List index out of bounds: 0
Class.EditClientComplianceCheckList_Controller.<init>: line 25, column 1"
And here is line 25 (and a few subsequent lines):
system.debug('ClientComplianceDocuments_List=='+ClientComplianceDocuments_List[0].Id+' name =='+ClientComplianceDocuments_List[0].Name);
ClientComplianceDocId_ComplianceDoc_Map = new Map<Id,Compliance_Document__c>();
ComplianceDocuments_NewlyAdded_Map = new Map<Compliance_Document__c,Boolean>();
Anyone have any insight?
Thanks!
Julien
isEmpty() Returns true if the list has zero elements.
if (!ClientComplianceDocuments_List.isEmpty()) {
system.debug('ClientComplianceDocuments_List=='+ClientComplianceDocuments_List[0].Id+' name =='+ClientComplianceDocuments_List[0].Name);
}
System.ListException: List index out of bounds: 0 = The list is empty ( [0] is the first element and it doesn't exist, second element, [1], third, [2] ...)