[SalesForce] Object Level Apex Sharing vs Record Level Apex Sharing

Is it possible to create Apex Sharing Rules that operate at an Object Level instead of an Individual Record Level?

When manually creating sharing rules in SFDC in the Sharing Settings of Setup Menu – you can create a rule that shares records owned by members of group 'A' with members of Group 'A'. This essentially performs an object level rule. Where in, if I edit group membership the sharing is automatically recalculated.

We are using Apex to create Public Groups and populate them with User Lookup Fields on a particular object. So essentially, every time a record on this object is created or edited the Public Group Membership is updated appropriately.

The Apex Sharing currently creates Sharing Rules at the Record Level for each record that needs to be shared with that group.

This presents a problem when an administrator would like to manually add members to Public Group. Since you cannot run a trigger on on the 'Group Member' object, sharing rules that need to additionally be created to support the manually added group member will never be created (unless we create a workaround to initiate Recalculating Apex with a Button of something).

So, I keep coming back to non apex based sharing rules and how these rules essentially work at the object level. Can this be accomplished in Apex Sharing?

Thank you in advance!

Best Answer

Object level permissions are typically controlled through profiles and permission sets. Sharing is only really needed for record-level permissions.

Related Topic