SF-PD2 Advanced Developer Fundamentals Practice Question
A developer is building an Apex class that must process records in batches and allow partial success, so that records failing validation are skipped while the rest commit. During testing, the developer notices that Database.insert(records, false) still throws a DmlException for a required-field violation instead of populating a SaveResult. What is the most likely cause?
⚠ Common exam trap
The trap here is assuming that any DmlException during a partial DML call proves allOrNone is ignored, when the exception usually comes from a different DML statement or the wrong overload.
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
✓
The call is actually Database.insert(records) with the default allOrNone of true, or the required-field error occurred during a separate DML statement.
In Apex, Database.insert with allOrNone false returns SaveResult objects and allows successful records to commit while failures are recorded. A required-field violation should therefore not throw. The observed exception means the effective mode was allOrNone true, either because the boolean overload was not used or because a different DML statement threw. Verifying the exact method signature and stack trace identifies the real cause.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The allOrNone parameter was passed as true because the records list is bound to a Visualforce page controller.
Why it's wrong here
Binding a list to a Visualforce page controller does not override the allOrNone argument passed to Database.insert. The DML option is determined by the literal argument in the call, not by the context in which the list is used. This explanation misattributes the behavior to the page binding, which cannot change how the allOrNone flag is interpreted during execution.
- ✗
A validation rule fired, and validation rules always throw DmlException regardless of the allOrNone setting.
Why it's wrong here
Validation rules do not always throw when allOrNone is false; they produce a SaveResult with success set to false and an error message. The allOrNone flag governs whether failures throw or are captured. Claiming validation rules override the flag is incorrect and would make partial DML impossible, which contradicts documented behavior.
- ✗
The DML call is inside a try block that catches DmlException, so the SaveResult list is discarded before it can be read.
Why it's wrong here
Catching DmlException does not discard SaveResult values when allOrNone is false, because no exception should be thrown in that mode. If an exception is thrown, the root cause is the mode, not the catch block. This explanation confuses exception handling with the DML mode semantics, so it does not explain why SaveResult is empty.
- ✓
The call is actually Database.insert(records) with the default allOrNone of true, or the required-field error occurred during a separate DML statement.
Why this is correct
With allOrNone false, a required-field violation yields a SaveResult and no exception. If a DmlException is thrown, the most likely cause is that the overload without the boolean was used, or another DML statement in the transaction failed. Inspecting the exact call and the stack trace reveals the true source of the exception.
About these practice questions
This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.