Sub topic 12
Sharing recalculation and what triggers it
This chapter assumes you know org-wide defaults, the role hierarchy, public groups, and how owner-based and criteria-based sharing rules work. It explains when Salesforce recomputes who can see which records, and what you can do about the delay.
What recalculation does
Salesforce stores access as share records and group membership data. When the inputs to those records change, the platform must rebuild them. This rebuild is called sharing recalculation. It evaluates every affected record against the current rules and then adds or removes access.
Recalculation works on the data that exists now. A rule you create applies to old records as well as new ones.
What triggers it
Some changes only affect one record. Others force a large rebuild.
| Change | Scope of recalculation |
|---|---|
| Change a record's owner | That record, and records related to it by ownership |
| Edit a field used in a criteria-based rule | That record |
| Create or edit a sharing rule | All records of the object |
| Change org-wide default for an object | All records of the object |
| Edit the role hierarchy or move a user to another role | Records owned by the affected users |
| Change public group or queue membership | Records shared through that group |
Single-record changes finish almost at once. Org-wide changes run as background jobs, and their duration depends on how much data the object holds.
Why ownership changes matter
Changing the owner is the most common trigger. When an account changes owner, Salesforce removes the sharing that came from the old owner. That includes the old owner's role-hierarchy access and any owner-based rule matches. It then adds the sharing that comes from the new owner.
Manual shares are also removed when the owner changes. Records the old owner shared by hand lose that access. Account team members stay unless the process removes them.
Deferred sharing calculations
Large changes can lock the sharing system for a long time. Salesforce offers two tools for this.
- Defer sharing calculations. An administrator can suspend automatic recalculation in Setup, under Defer Sharing Calculations. You then make several changes, such as loading data or editing groups and rules.
- Resume and recalculate. When you finish, you resume calculations. Salesforce processes all pending changes in one pass, which is faster than many separate passes.
You can also run a manual recalculation for an object's sharing rules. In Setup, open Sharing Settings and use the Recalculate button next to the rule list. Do this when a rule shows as out of date or when a rule failed to apply.
How the order fits together
Common errors
- Expecting immediate access after editing a rule. Check the status in Setup before debugging.
- Changing the org-wide default for a busy object during working hours.
- Forgetting that a new owner wipes manual shares made by the old owner.
- Leaving deferred sharing on after a data load.
Exercise
An admin must load 200,000 accounts, then edit three sharing rules and several public groups. How can the admin reduce total recalculation time, and what must be done afterward?
Show answer
Defer sharing calculations before the load and the edits, make all the changes, then resume calculations so Salesforce processes everything in one pass. Afterward, confirm the recalculation has finished and that calculations are no longer deferred.