Salesforce Certified Sharing and Visibility Designer — Question 9
Cloud Kicks has the following setup and requirements:
A strict software architecture for their custom Apex code.
All SOQL queries must be contained within reusable classes.
Depending on the context of the Apex transaction, the queries should be able to run either “With Sharing” or “Without Sharing”.
What are two methods for meeting these requirements? (Choose two.)
Answer options
- A. 1. Create a SystemSOQLQueries class and a UserSOQLQueries class. 2. Set the “With Sharing” keyword on the UserSOQLQueries class and “Without Sharing” on the SystemSOQLQueries class.
- B. 1. Create a reusable SOQLQueries class. 2. Specify “With Sharing” on the methods that require user context and “Without Sharing” on the methods requiring system context.
- C. 1. Create a reusable SOQLQueries class. 2. Do NOT specify “With” or “Without Sharing” on the SOQLQueries class and use the runAs() method to dynamically set the context.
- D. 1. Create a reusable SOQLQueries class. 2. Do NOT specify “With” or “Without Sharing” on the SOQLQueries class.
Correct answer: A, D
Explanation
Option A is correct because it effectively segregates the SOQL queries into classes that can individually manage their sharing settings. Option D is also correct as it allows for the creation of a reusable class without specifying sharing settings, which can be useful in certain contexts. Options B and C do not meet the requirement of containing SOQL queries within classes that explicitly manage sharing settings as specified in the question.