2

I am trying to programmatically share a custom object (Widget__c) with a Public Group using apex managed sharing. For every Widget record that gets created, it is associated with a custom object Widget_Group__c. Widget_Group__c to Widget__c is a one to many relationship...i.e. one group to many widgets. Widget_Group__c just stores the group name and a few other fields. There is actually public group with the same name that I will use for the share. When the Widget record is created, I am looking to fire a trigger that shares that widget record with the public group that has the same name as the Widget_Group__c.

Now, there can be lots (thousands) of Widget records and there can potentially be and will very likely be over 50 widget_group__c group records.

It looks like I can create the trigger to share the widget record with the public group. However, I'm concerned about the sharing limit.

If I have hundreds or even thousands of Widget records that will need to be shared with hundreds or thousands of groups, is this approach going to ultimately fail?

It is basically a criteria based sharing rule created programmatically.

1 Answer 1

2

It appears to me that you're actually better off going with Apex Managed Sharing than you would be if you were to try using Criteria Based Sharing. The limit on Criteria Based Sharing is 50 criteria-based rules per object. You won't need to deal with that limit using Apex Managed Sharing. All you'll need to do is create a Sharing Reason for a Record on the Object.

Your limits on the number of Public Groups for sharing wouldn't be any different for Apex Managed Sharing vs the Other Sharing methods. As a best practice, Salesforce recommends that you limit the total number of public groups for an organization to 100,000 and that you don't nest them more than 5 levels deep. Nesting has an impact on group maintenance and performance due to group membership calculation. See A Guide to Sharing Architecture for more.

You must log in to answer this question.

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