Salesforce Certified Platform Developer II — Question 218
Which statement is considered a best practice for writing bulk safe Apex Triggers?
Answer options
- A. Add records to collections and perform DML operations against these collections
- B. Instead of DML statements, use the Database methods with allOrNone set to False
- C. Add LIMIT 50000 to every SOQL statement
- D. Perform all DML operations from within a Future Method
Correct answer: A
Explanation
Option A is correct because adding records to collections and performing DML operations on these collections helps in handling bulk data efficiently and avoids hitting governor limits. Option B is not a best practice as using allOrNone set to False can lead to partial successes, which may not be desirable in all scenarios. Option C is incorrect because adding LIMIT 50000 to SOQL statements is not an effective way to ensure bulk safety and may not always be necessary. Option D is wrong since performing DML operations in a Future Method can lead to complications and doesn't inherently make the trigger bulk-safe.