Salesforce Certified Sharing and Visibility Designer — Question 2
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 does not have create permission on the Order object.
Correct answer: B
Explanation
The correct answer is B because using 'with sharing' enforces sharing rules, which means that if the user does not have access to the related orders, they will encounter permission errors. Option A is incorrect because the absence of sharing keywords would not lead to the same error under the described conditions. Options C and D are also incorrect as they do not directly address the sharing and permission access issue causing the error.