I am studying "Apex Managed Sharing" but I have a problem with "Recalculating Apex Managed Sharing".

The Apex Developer Guide says:

Every time a custom object's organization-wide sharing default access level is updated, any Apex recalculation classes defined for associated custom object are also executed.

I have created an Apex Class implementing Database.Batch interface and I have assigned this class for my Custom Object.

If I start the Recalculation from UI the code run correctly but if I change OWD the code is not executed.

  • 1
    update OWD from Public Read Only or Public Read Write to Private, and check what happens Feb 7, 2018 at 14:57
  • 1
    Please always link to any resource you cite in your posts. That said, I think the documentation is just wrong here. Not sure how they would tell which batches should even execute unless there were a separate interface.
    – Adrian Larson
    Feb 7, 2018 at 15:03
  • @SantanuBoral I have done these test but nothing has happened
    – vt89
    Feb 7, 2018 at 15:08
  • 2
    @AdrianLarson, the documentation he linked to shows how to "associate an Apex managed sharing recalculation class with a custom object" all the way at the bottom. Feb 8, 2018 at 2:38
  • @DanielHoechst and therein lies the likely answer. That step seems almost certainly missed here.
    – Adrian Larson
    Feb 8, 2018 at 2:44

2 Answers 2


To associate an Apex managed sharing recalculation class with a custom object:

  1. From the management settings for the custom object, go to Apex Sharing Recalculations.
  2. 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.
  3. Click Save.

To run an Apex sharing recalculation, from the management settings for a custom object, go to Apex Sharing Recalculation, and then click New.

When working with Apex sharing recalculations, note the following.

  1. The Apex code that extends the sharing recalculation can process a maximum of five million records. If thisApex code affects more than five million records, the job fails immediately.
  2. You can monitor the status of Apex sharing recalculations in the Apex job queue.
  3. You can associate a maximum of five Apex sharing recalculations per custom object.
  4. You cannot associate Apex sharing recalculations with standard objects.
  • I can't see apex sharing recalculation in the object settings , my custom object is set to private
    – Jojosfdc
    May 18, 2022 at 9:57

I think I finnaly found the solution, you will only be able to see the apex sharing reasons and apex sharing Recalcultation categories if you switch to classic and navigate to your object in setup.

enter image description here

You must log in to answer this question.

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