SF-PD2 Process Automation, Logic, and Integration Practice Question
A developer is implementing a complex business process that requires calling an external web service, then updating multiple related records, and finally sending an email. The entire process must be atomic; if any step fails, all changes must be rolled back. Which approach should the developer use?
⚠ Common exam trap
The trap here is assuming that Salesforce transactions can provide atomicity across external callouts, or that Queueable chaining can achieve all-or-nothing behavior.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Implement a compensation mechanism: perform the callout, then DML in a separate transaction, and if DML fails, invoke a compensating callout to undo the external action.
Atomicity across external callouts and Salesforce DML is not natively supported because callouts cannot be rolled back. The developer must use a compensation pattern: if the subsequent DML fails, a compensating callout is made to undo the external action. This ensures that the overall process either completes fully or is compensated, maintaining data integrity across systems.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use a Database.Savepoint and rollback in a single transaction, with the callout performed before the savepoint.
Why it's wrong here
Savepoints can roll back DML within a transaction, but they cannot roll back a callout. If the callout occurs before the savepoint, it is not covered. If after, it violates the callout-DML order. Additionally, email is not rolled back. Savepoints do not provide atomicity across external calls.
- ✗
Perform all operations in a single Apex transaction, using a callout followed by DML and email.
Why it's wrong here
A single transaction cannot contain a callout followed by DML due to the uncommitted work restriction. Also, email sent via Apex is not rolled back if the transaction fails. This approach would violate the atomicity requirement because the callout cannot be undone, and email is not transactional.
- ✗
Use a Queueable Apex job to perform the callout, then chain a second Queueable to perform DML and send email.
Why it's wrong here
Chaining Queueables separates the callout and DML into different transactions, but this breaks atomicity. If the second job fails, the callout cannot be rolled back. Also, email is not rolled back. This approach does not guarantee all-or-nothing behavior.
- ✓
Implement a compensation mechanism: perform the callout, then DML in a separate transaction, and if DML fails, invoke a compensating callout to undo the external action.
Why this is correct
Since true atomicity across external systems is impossible with Salesforce transactions, the developer must implement a compensation pattern. This involves performing the callout, then DML in a separate transaction, and if DML fails, calling the external service again to reverse the action. This achieves eventual consistency and is the standard approach for distributed transactions.
About these practice questions
Courseiva writes every SF-PD2 question from scratch — 226 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Salesforce exam blueprint
This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.