I have below method and error is coming beacuse of some validation/trigger is on account and need to catch the exception If i am runnning this from Ui for one record this will throw an exception as i am using[0],
but what in case i am using data load and inserting/updating 5 records and if the exception is for 3rd record,still it will throw for first record only. Please suggest how to handle this
public static void updatecon(list<account>conlist){
for (contact con: conlist){
Ids.put(con.accountId, con.Id);
}
for(Account acc: [Select Id, vlocity_cmt__PersonContactId__c, Type from Account where Id In:Ids.keyset()]){
Account acnt = new Account();
acnt.Id = acc.Id;
acnt.status = 'Inactive';
AccList.add(acnt);
}
if(AccList.size()>0){
try{
update AccList;
}
catch(dmlexception e){
conlist[0].adderror(e.getMessage());
}
}
}