When developing a custom screen that requires both an Account and Contact to be created together, using setSavepoint() and rollback() within a try-catch block is a reliable way to ensure that if the Contact creation fails, the Account creation is also rolled back, maintaining data integrity.
[References: Apex Developer Guide - Savepoint and Transaction Control]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit