nerdexam
Salesforce

PDII · Question #291

PDII Question #291: Real Exam Question with Answer & Explanation

Sign in or unlock PDII to reveal the answer and full explanation for question #291. The question stem and answer options stay visible for context.

Question

A business requires that every parent record must have a child record. A developer writes an Apex method with two DML statements to insert a parent record and a child record. A validation rule blocks child records from being created. The method uses a try/catch block to handle the DML exception. What should the developer do to ensure the parent always has a child record?

Options

  • AUse addError() on the parent record if an error occurs on the child record.
  • BSet a database savepoint to rollback if there are errors.
  • CUse Database.insert() and set the allOrNone parameter to true.
  • DDelete the parent record in the catch statement when an error occurs on the child record DML

Unlock PDII to see the answer

You've previewed enough free PDII questions. Unlock PDII for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Full PDII Practice