You need to sign in to do that
Don't have an account?
kiran punuru
How to get the failed to update record ids
Hi ,
I Have list of 10 accounts which i need to update out of that 10 records 5 records get updated and 5 records get failed to update due to validation rules ,Is there a way to get the failed record ids .any ideas ??
Thanks
Kiran
I Have list of 10 accounts which i need to update out of that 10 records 5 records get updated and 5 records get failed to update due to validation rules ,Is there a way to get the failed record ids .any ideas ??
Thanks
Kiran
One edit to the code provided by Nayana.
Add Database.SaveResult to beginning of the followng line.
Please check the reference solution:
public virtual class MyClass{
public static void myMethod(){
List<Opportunity> oppList = new List<Opportunity>();
Opportunity opp1 = new Opportunity();
opp1.Name = 'Mithun';
opp1.Id = '0065g00000UtO5bAAF';
opp1.StageName = 'Prospecting';
opp1.CloseDate = date.today();
oppList.add(opp1);
Opportunity opp2 = new Opportunity();
opp2.Name = null;
opp2.Id = '0065g00000UtO5cAAF';
opp2.StageName = 'Qualification';
opp2.CloseDate = date.today();
oppList.add(opp2);
List<Database.SaveResult> srList = Database.update(oppList,false);
for(Database.SaveResult sr : srList){
if(sr.isSuccess()){
system.debug('Successfully updated id is :'+sr.getId());
}else{
system.debug('Failed to update id is :'+sr.getId());
}
}
}
}