Sharing Objects Part 3
Contents
[NOTE] Updated February 20, 2020. This article may have outdated content or subject matter.
The past two previous discussions were primarily based on the Sharing model and managed programmatic sharing on the Salesforce platform. This post will be focused on recalculating apex managed sharing. What does it mean to recalculate sharing?
Sharing Recalculation
Salesforce automatically recalculates sharing for all records on an object when its organization-wide sharing default access level changes. The recalculation adds managed sharing when appropriate. Also, all types of sharing are removed if the access they grant is considered redundant. For example, manual sharing, which grants Read-Only access to a user, is deleted when the object’s sharing model changes from Private to Public Read Only. >To recalculate Apex managed sharing, you must write an Apex class that implements a Salesforce-provided interface to do the recalculation. You must then associate the class with the custom object, on the custom object’s detail page, in the Apex Sharing Recalculation related list. The above can be accomplished using batchable apex to mass update shared records. Also please bare, in mind Apex sharing reasons and Apex managed sharing recalculation are only available for custom objects.
Every time a custom object’s organization-wide sharing default access level is updated, any Apex recalculation classes defined for the associated custom objects are also executed.
|
|
Associating an Apex Class Used for Recalculation
An Apex class used for recalculation must be associated with a custom object. - Switch salesforce classic, navigate to the Essence object page details - Go to Apex Sharing Recalculations section - Choose the Apex class that recalculates the Apex sharing for this object. The class you choose must implement the Database.Batchable interface. You cannot associate the same Apex class multiple times with the same custom object. - Click Save.
Author Remario Richards
Modified February 20, 2020