Sub topic 15
Designing a Sharing Model: Start Restrictive, Keep the Hierarchy Simple
This chapter assumes you know how org-wide defaults (OWD), ownership, roles and the role hierarchy combine. It also assumes you know what sharing rules, teams and manual sharing do. Here you will use that knowledge to design a sharing model. You will make decisions in a fixed order, and you will see the trade-offs and the mistakes that cause trouble later.
The core principle: restrict first, then open
Salesforce sharing can only widen access. You can't use it to take access away from a user. OWD sets the floor for each object. The role hierarchy, sharing rules, teams and manual shares then add access on top of it.
That one-way behavior is why you start restrictive. If you set an object to Public Read/Write and later find that it holds sensitive data, you can't fix it by adding a rule. You have to tighten the OWD, then rebuild the access that people legitimately need. Going the other way is easy: you set Private and add access where there is a business reason.
A decision sequence
Work through these steps for each object, in this order.
- Decide who must never see the record. If the answer is "nobody in the org," the OWD can be public. If some internal users must be excluded, OWD must be Private (or Public Read Only if they may read but not edit).
- Set the most restrictive OWD that still fits the most restricted user. The OWD must suit the person who should see the fewest records.
- Check whether the role hierarchy already gives the right access. Managers see what their reports own. If that matches your business, stop here.
- Add owner-based sharing rules for groups of users who are not in a direct line, such as a sales operations team.
- Add criteria-based sharing rules when access depends on field values, such as Region equals EMEA.
- Use teams and manual sharing for exceptions that vary record by record.
- Use Apex managed sharing only when none of the declarative tools can express the rule.
The order matters because each step is more expensive to maintain than the one before. A hierarchy needs no upkeep once it exists. Sharing rules need review when the org changes. Manual shares and Apex shares need the most attention and are the hardest to audit.
Choosing an OWD per object
Think about each object separately. Related objects often need different settings.
| Object type | Typical OWD | Reason |
|---|---|---|
| Account (sales-led org) | Private or Public Read Only | Customer data is valuable, and ownership drives selling |
| Opportunity | Private | Deal values are often sensitive between reps |
| Contact | Controlled by Parent | Access follows the account, which avoids drift |
| Case | Private or Public Read Only | Depends on whether agents work shared queues |
| Reference data (price books, campaigns) | Public Read Only | Everyone needs to read it, few should edit it |
| Custom object with confidential data | Private | Restrictive by default |
Two points to watch:
- Controlled by Parent makes the child's access follow the parent record. It is a good choice for detail records in a master-detail relationship. It also keeps you from setting up the same sharing twice.
- Account OWD and its related objects. Opportunity and Case access on an account is set by role-based settings on the account's sharing rules. If Account is Private but Opportunity is Public Read Only, you can end up with users who can read an opportunity but not its account. Check that the combination is intentional.
Keeping the role hierarchy simple
The role hierarchy exists to give managers access to their reports' records. It does not need to copy the org chart. A common mistake is to model every team, level and reporting line as a role.
Follow these guidelines.
- Use the fewest roles that still produce the right upward access. Each extra level adds to sharing calculation and to the number of people who can see a record.
- Keep the hierarchy shallow. Aim for a small number of levels. Very deep hierarchies make access hard to predict and slow down recalculation.
- Don't create roles to control field or object access. Profiles and permission sets do that. A role only affects which records a user can reach through the hierarchy, and through role-based sharing rules and public groups.
- Don't give every user a unique role. Users who need the same record visibility can share a role.
- Avoid parent roles with huge numbers of direct children where possible, and avoid owning large numbers of records under one user. A single owner with a very large number of child records can cause locking and slow sharing recalculation. Spread ownership across several users or use assignment rules.
- Treat a role change as an access change. Moving a user to a different role changes which records they and their managers can see, and triggers recalculation.
Use groups and queues instead of individuals
When a sharing rule applies to specific people, point it at a public group, a role, or a role and subordinates. Do not point it at a single user. Groups let you add and remove members without editing rules. A rule that names one user breaks quietly when that person leaves.
Plan for external users
External users, such as Experience Cloud users, have their own OWD for each object. The external OWD can be the same as the internal one or more restrictive. It can never be more open than the internal OWD. A typical design is Private for external users and Public Read Only or Private for internal users. Then you open access to external users with sharing sets or share groups, not by loosening the external OWD.
Document the model and test it
A sharing model that nobody can explain is hard to change safely. Keep a short record that lists, for each object, the OWD, the reason for it, and each sharing rule with its business purpose.
Test with real users or with the Login as feature in a sandbox, and check results with the queries from earlier chapters. This query shows whether a specific user can reach a specific record after every sharing mechanism has been applied:
SELECT RecordId, HasReadAccess, HasEditAccess, HasDeleteAccess
FROM UserRecordAccess
WHERE UserId = '005XXXXXXXXXXXXXXX'
AND RecordId = '001XXXXXXXXXXXXXXX'This one shows why access exists for one account, through the RowCause field:
SELECT Id, AccountId, UserOrGroupId, AccountAccessLevel, RowCause
FROM AccountShare
WHERE AccountId = '001XXXXXXXXXXXXXXX'Run these for at least three users: one who should have access, one who should not, and one who is a manager of the owner. A design is only correct when all three results match your intent.
Common design mistakes
| Mistake | Effect | Better approach |
|---|---|---|
| Setting OWD to Public Read/Write for convenience | Anyone can edit any record, and you can't tighten it with sharing | Start at Private and add access |
| Giving many users View All or Modify All | Bypasses sharing entirely, so the model stops working | Reserve these for administrators and integration users |
| Building roles to match job titles | Deep, brittle hierarchy | Build roles around visibility needs |
| Many overlapping sharing rules | Hard to audit, and slow recalculation | Merge rules and use public groups |
| Using manual sharing as the main tool | Access is lost when the owner changes | Use a rule or team for repeatable needs |
| Relying on the Sharing button for a permanent need | Manual shares are removed on ownership change | Use a sharing rule |
Worked example
A company has sales reps, regional managers and a sales operations team. Reps must not see each other's accounts. Managers must see their region. Sales operations must read all accounts.
- Set Account OWD to Private. Reps then see only their own accounts.
- Create roles: VP Sales, then three Regional Manager roles, then Rep roles under each region. The hierarchy gives managers their region and the VP everything.
- Sales operations are not in the chain above any rep. Create a public group and an owner-based sharing rule that gives it Read Only access to accounts owned by the VP Sales role and subordinates.
- Set Contact to Controlled by Parent, so contact access follows the account.
- Check with
UserRecordAccessfor a rep in another region, a manager, and a sales operations user.
The design uses one OWD, a three-level hierarchy and one sharing rule. Nothing needs Apex.
Exercise
A custom object holds salary review notes. HR staff must edit them, each employee's manager must read their own team's notes, and nobody else may see them. Which OWD would you pick, and how would you give access to HR?
Show answer
Set the OWD to Private, because it must suit the users who should see the fewest records. Managers get read access through the role hierarchy, provided Grant Access Using Hierarchies is enabled and the managers sit above the record owners. For HR, put them in a public group and create a sharing rule that gives that group Read/Write access to the records. Use a rule rather than manual shares so the access lasts when owners change.
Exercise
Why is setting an OWD to Public Read/Write "to fix an access problem" a poor choice, and what should you do first?
Show answer
Sharing only adds access, so a wide OWD can't be narrowed by any other sharing setting. It also gives every user edit access to every record. First find why the user lacks access, using UserRecordAccess and the share table, and then add the narrowest tool that fixes it, such as a sharing rule or team.