Skip to main content

@Ladies Be Architects i am studying for the sharing and visibility exam and i encountered some difficulties on choosing the correct solution:

My company 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.

Should can be he right way to do this?

A) create an AccountShare record associated to the required role

B)create an AccountShare record associated to a public group containing the users in the role

C)create an AccountShare record associated to each user who is assigned to the role

D)create an AccountShare record associated to a public group containing the role

 

i was reading on this topic and i find hard to give the right solution , in the sharing table, it says 

"The Id of the User to whom you are granting access. May also be a Public Group Id. When sharing to a role, you cannot assign Role Id to UserOrGroupId field directly. It should instead be a matching Group Id from Group table. This field cannot be updated."

Any idea of this solution?

Thanks.

O

4 comments
  1. Sep 25, 2024, 1:46 PM

    D : The recommended way for the architect to implement this is to create an AccountShare record associated to a public group containing the role. This way, the architect can use Apex Managed Sharing to share certain account records with all users who are assigned to a specific role in the role hierarchy. Creating an AccountShare record associated to a public group containing the users in the role is not possible because public groups can only contain users, roles, or other public groups, but not a combination of them. Creating an AccountShare record associated to each user who is assigned to the role is not efficient because it requires more sharing records and maintenance. Creating an AccountShare record associated to the required role is not valid because AccountShare records can only be associated to users or groups, not roles

0/9000