System.ListException: List index out of bounds: 0 from Trigger

This means that your query has returned no records that match the criteria.  If you then attempt to access an element at row 0 like lrecords[0], this will throw an error as that row doesn't exist.

Its good practice to check list size before you proceed to call this :

List<custom obj__c> lrecords=[
                       select Id,name,
                              from Object1__c   
                 ];
if (lrecords.size()>0) // Please use this before accessing array

{

lrecords[0].Fileld1__c = 2; lrecords[0].Fileld2__c =3; update lrecords;

}

Post a Comment

0 Comments