PDI · Question #78
PDI Question #78: Real Exam Question with Answer & Explanation
The correct answer is D: Use the Database method with all or None set to false. When DML operations within a trigger might cause issues for downstream integrations due to partial failures, using Database.insert() with allOrNone set to false allows successful records to be inserted while ignoring failures for problematic ones.
Question
A developer created a new trigger that inserts a Task when a new Lead is created. After deploying to production, an outside integration chat reads task records is periodically reporting errors. Which change should the developer make to ensure the integration is not affected with minimal impact to business logic?
Options
- ADeactivate the trigger before the integration runs.
- BUse a try-catch block after the insert statement.
- CRemove the Apex class from the integration user's profile.
- DUse the Database method with all or None set to false
Explanation
When DML operations within a trigger might cause issues for downstream integrations due to partial failures, using Database.insert() with allOrNone set to false allows successful records to be inserted while ignoring failures for problematic ones.
Common mistakes.
- A. Deactivating the trigger before the integration runs would completely stop the business logic of creating tasks for new leads, which is not a minimal impact solution.
- B. A
try-catchblock around the insert statement would catch the exception, but without specific handling for partial success, it might still prevent any tasks from being created if an error occurs for even one record. - C. Removing the Apex class from the integration user's profile would prevent the trigger from executing entirely for that user, stopping the business logic of creating tasks and not offering a minimal impact solution for errors.
Concept tested. Apex DML options (partial success)
Topics
Community Discussion
No community discussion yet for this question.