Let's say in Apex you have multiple DML calls like update opportunity then you update Account and then you update contact, but it fails on contact so you want to undo the update on Account and opportunity how do you implement that?


1 Answer 1


Assuming that all 3 of your DML statements are happening in the same transaction, this is what happens by default if you don't catch the DMLException. I.e. There is nothing for you to implement.

When an exception goes unhandled (and thus the entire transaction fails), Salesforce rolls back the changes made as part of that transaction.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .