Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 310 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 310
Topic #: 1
[All Certified Platform Developer II Questions]

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?

  • A. Use addError() on the parent record if an error occurs on the child record.
  • B. Set a database savepoint to rollback if there are errors.
  • C. Use Database.insert() and set the allOrNone parameter to true.
  • D. Delete the parent record in the catch statement when an error occurs on the child record DML operation.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
corpex
6 months, 1 week ago
Selected Answer: B
A and D won't undo any potencial change to related records when you delete or adderror the parent. C is not useful in this scenario since you need the parent Id to be inserted first. So answer is B
upvoted 1 times
...
RatnaB
8 months, 2 weeks ago
D is the correct answer
upvoted 1 times
...
M4JK3LSON
10 months, 4 weeks ago
Ugly question again - please tell me how it is possible to ensure that parent record ALWAYS (so in insert scenario too) have at least one child record when inserting child record REQUIRES parent Id to mark it's record as a child of another record. Parent record Id becomes avaliable the earliest in after insert trigger context 🤣
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...