Salesforce Certified Sharing and Visibility Architect — Question 8
After testing and deploying a new trigger that creates a related order when an opportunity is closed, the Architect begins receiving complaints of permission error messages appearing when closing an opportunity.
How did this error occur?
Answer options
- A. The trigger handlers class does not use any sharing keywords and the user does not have access to the orders related to the opportunity.
- B. The trigger handler class is using “with sharing” and the user does not have access to the orders related to the opportunity.
- C. The trigger should be using RunAs() when creating the order.
- D. Trigger is using IsCreateable() Apex method and the user doe not have create permission on the Order object.
Correct answer: D
Explanation
The correct answer is D because the IsCreateable() method checks if the user has permission to create a record, and if they lack permission on the Order object, an error will occur. Option A is incorrect as it doesn't involve sharing keywords, and B is wrong because having 'with sharing' would not cause a permission issue if the user had access. Option C is also incorrect since RunAs() is used for testing purposes and not relevant to this scenario.