SF-PD2 Process Automation, Logic, and Integration Practice Question
A financial services organization is building a high-volume custom REST API endpoint using Apex to handle incoming transactions from an external core banking system. The integration must ensure strict data integrity, handle partial batch failures gracefully, and process up to 200 records per request. Which TWO practices must the developer implement to satisfy these requirements? Choose 2 answers.
⚠ Common exam trap
Candidates often use standard DML statements, which cause the entire transaction to roll back on a single failure, rather than using partial DML to ensure data integrity.
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
✓
Utilize Database.insert(records, false) and iterate through the returned Database.SaveResult array to identify individual failures and construct a detailed response payload.
Using Database.insert(records, false) allows partial success processing, enabling the system to isolate failing records while committing valid ones. Returning a structured JSON response with detailed error mappings ensures the external system can reconcile transactions effectively. These patterns are vital for enterprise integration reliability and robust error handling.
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 standard Database.insert(records, true) to ensure that any single validation error rolls back the entire incoming transaction batch.
Why it's wrong here
Passing true as the allOrNone parameter enforces atomic transactions, meaning one invalid record causes the entire batch of 200 to fail. Enterprise banking integrations typically require partial batch processing to avoid rejecting valid financial transactions due to isolated errors.
- ✓
Utilize Database.insert(records, false) and iterate through the returned Database.SaveResult array to identify individual failures and construct a detailed response payload.
Why this is correct
Allowing partial success with Database.insert and evaluating SaveResult instances gives developers granular control over error handling. This pattern ensures valid records are persisted while exact failure reasons are captured and returned to the calling external system.
- ✗
Throw a custom CalloutException immediately upon encountering a validation error to force the Salesforce platform to rollback the REST transaction automatically.
Why it's wrong here
Throwing unhandled exceptions terminates the entire transaction and returns a generic 500 server error to the caller, losing valuable context about specific record failures. REST APIs should return structured application-level error codes rather than raw platform exceptions.
- ✓
Serialize custom error DTO objects into the HTTP response body, mapping failed record IDs to specific error messages extracted from the SaveResult errors.
Why this is correct
Returning a structured DTO payload containing specific record IDs and corresponding error messages allows the external client to reconcile its state. This level of transparency is essential for maintaining data synchronization between distributed enterprise systems.
- ✗
Rely solely on standard Apex exception logging via System.debug statements to capture transaction failures without returning response bodies.
Why it's wrong here
System.debug writes to debug logs only, so callers receive no failure detail and partial batch failures cannot be reconciled by the core banking system. Debug logging suits developer troubleshooting, whereas the requirement demands structured response bodies returning per-record success or error status.
About these practice questions
One of 226 original SF-PD2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.