10

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!

4
  • 1
    Could you add a little bit about your specific use-case? Most of what you're describing sounds like uses that could be accomplished with standard out features, i.e. org wide defaults, role hierarchies, and sharing rules, but I'm guessing we're missing something about your scenario. Commented Oct 21, 2013 at 16:56
  • Certainly, the use-case is this... We are an SFDC ISV Partner with a CRM agnostic product. Typically, users interact with groups of records across many objects that ultimately 'logically' relate to business functions at a company. This presents a user administration challenge. Commented Oct 22, 2013 at 20:44
  • Users interact with groups of records across many objects that ultimately 'logically' relate to business functions at a company. This presents a user administration challenge. Our customer admins end up managing 100s of sharing rules across 5-10 diff objects. We are trying to minimize user admin - our apex sharing model automatically creates Public Groups populated with User Look Up fields on an Object Record. The sharing rules are then auto created for the 'related objects records'. The question is can you create apex sharing that mimics the abilities of 'criteria-based sharing rules Commented Oct 22, 2013 at 20:52
  • Unfortunately not that I'm aware of, the approach your taking sounds like a reasonable one. It's difficult to fully understand your needs, but this feels like something that would need to be addressed by wider sharing changes (i.e. redesign the role hierarchy, groups, and sharing rules). It may also be good to question whether a private sharing model is really worth all the effort your putting into maintaining it. Commented Oct 23, 2013 at 16:49

1 Answer 1

4

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .