Sub topic 7
Owner-based sharing rules
An owner-based sharing rule gives a group of users access to records that other users own. It opens access beyond the org-wide default (OWD) for a specific set of record owners. This chapter assumes you know what OWD, the role hierarchy, and public groups are, and that you can open Setup.
What the rule contains
Every owner-based rule answers three questions:
- Whose records? The records owned by members of a public group, a role, or a role and its subordinates.
- Who gets access? A public group, a role, or a role and its subordinates.
- At what level? Read Only or Read/Write.
The rule only matters when the OWD for the object is Private or Public Read Only. If the OWD is Public Read/Write, nobody can gain more access, so the rule has no effect.
Worked example
The Finance team owns invoices in a custom object, Invoice__c, whose OWD is Private. Support managers need to read those invoices.
- Go to Setup and search for Sharing Settings.
- Find the Invoice Sharing Rules list and click New.
- Enter the label Finance Invoices to Support Managers.
- Choose the rule type Based on record owner.
- Under Owned by members of, choose Public Groups and select
Finance_Team. - Under Share with, choose Public Groups and select
Support_Managers. - Set Access Level to Read Only and save.
Salesforce then recalculates sharing. Every invoice owned by a member of Finance_Team now has a share row for Support_Managers.
Choosing the source and target
Roles work well when the org's structure already matches the need. Public groups work better when the people are scattered across roles. The options differ in who they include.
| Option | Includes |
|---|---|
| Roles | Users in that role only |
| Roles and Subordinates | Users in that role and every role below it |
| Public Groups | Any mix of users, roles, and other groups |
If you share with a role and its subordinates, the users in roles above it still gain access through the role hierarchy, provided the object's Grant Access Using Hierarchies setting is on.
Common errors
- Rule has no effect. The OWD is already Public Read/Write, or the user already had access through another path.
- Wrong group selected. Owner-based rules look at who owns the record, not at who created it. If ownership changes, the record leaves or enters the rule's scope.
- Expecting Read/Write to override object permissions. A rule grants record access only. The user still needs the object permission (such as Edit) from a profile or permission set.
- Queue-owned records. A rule that targets owners who are members of a public group does not match records owned by a queue, unless the queue itself is included as a source.
- Expecting instant results on a large org. Rule changes trigger recalculation, which can take a while. The recalculation chapter covers this.
Check the result
You can confirm the rule worked by querying the share table. Rule-created rows have a RowCause of Rule.
SELECT Id, ParentId, UserOrGroupId, AccessLevel, RowCause
FROM Invoice__Share
WHERE ParentId = '<invoice record Id>'You should see a row for the Support_Managers group with AccessLevel of Read and RowCause of Rule.
Exercise
The OWD for Invoice__c is Public Read/Write. You create an owner-based rule that shares Finance-owned invoices with SupportManagers at Read Only. What changes for SupportManagers, and why?
Show answer
Nothing changes. With Public Read/Write, every user can already read and edit every invoice, and a sharing rule can only widen access. A rule with Read Only access does not reduce it either. To make the rule meaningful, the OWD would first have to be set to Private or Public Read Only.
Exercise
A support manager can see a Finance invoice, but the Edit button is missing even though the rule grants Read/Write. Name two things to check.
Show answer
First, check the user's object permissions on Invoice__c in their profile or permission sets, because a sharing rule does not grant the Edit permission. Second, query Invoice__Share for that record to confirm the rule's row has an AccessLevel of Edit. Also check whether a validation rule or a locked record is blocking the edit.