You need to sign in to do that
Don't have an account?
pooja biswas
exception handling in apex
Hi
I have a class which will update account field and contact field if some change occurs in opportunity.
I am calling instance of this class inside trigger written on opportunity object.
I am using Database.Update statement to perform DML .
Now if an error occurs while updating the contact field, then I should roll back the entire transaction including account.
Please let me know how to achieve this.
Thanks
Pooja
I have a class which will update account field and contact field if some change occurs in opportunity.
I am calling instance of this class inside trigger written on opportunity object.
I am using Database.Update statement to perform DML .
Now if an error occurs while updating the contact field, then I should roll back the entire transaction including account.
Please let me know how to achieve this.
Thanks
Pooja
Try specifying a boolean parameter allorNone along the with list of sobject to update .
For Eg:
Database.update(ListofAccounts,true);
This will rollback all the transaction in the context .
check for the following method in Database class.
update(recordToUpdate, allOrNone)
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database.htm
Please let us know, if this solves your problem.
Thanks