SHARING-AND-VISIBILITY-DESIGNER practice question 4 of 30

Universal Containers has a private sharing model on Accounts. Apex Managed Sharing is required to share certain account records with all users who are assigned to a specific Role in the Role Hierarchy. What should be the recommended way for the Architect to implement this?

Full set: 212 questions
Answer options
A: Create​​an​​AccountShare​​record​​associated​​to​​a​​public​​group​​containing​​the​​Users​​in​​the​​Role.
B: Create an AccountShare record associated to each user who is assigned to the Role.
C: Create an AccountShare record associated to the required Role.
D: Create an AccountShare record associated to a public group containing the Role. ​ Correct answer
Correct Answer:
D. Create an AccountShare record associated to a public group containing the Role. ​
Explanation

The most scalable and maintainable method to implement this requirement is to create a public group that contains the specified Role. Then, use Apex to create a single AccountShare record for each Account to be shared, setting the UserOrGroupId to the ID of this public group. This approach is efficient because it requires only one share record per Account, regardless of the number of users in the role. It is also maintainable, as any changes to the role's user membership are automatically reflected in the group's membership without any further administrative effort.

Why Incorrect

A. A public group containing individual users is not maintainable. As users change roles, the group membership would need to be updated manually.
B. Creating a share record for each user is not scalable and can lead to performance issues and hitting sharing limits, especially with many users or records.
C. Sharing directly to a Role ID is possible, but it does not grant access to users in subordinate roles. Using a group provides this flexibility if needed.

References

1. Salesforce Developers, Apex Developer Guide, "Sharing a Record Using Apex". This guide details how to create Share objects, specifying the UserOrGroupId which can be a User ID or a Group ID.

2. Salesforce, Sharing and Visibility Designer Study Guide, "Programmatic Sharing" section. Best practices emphasize using groups for sharing to simplify management and improve performance. It states, "Share to a public group or role whenever possible to reduce the number of records and improve performance."

3. Salesforce Help, Create and Edit Groups. This document explains that public groups can contain roles, roles and subordinates, or other groups, which is the foundation for this scalable sharing pattern.

Scroll to Top