Sub topic 1
How Salesforce Layers Data Access
This chapter gives you the working model for how Salesforce decides who can see and change a record. Every later chapter on sharing rules, manual sharing, and teams adds one mechanism to this model.
Prerequisites
This chapter assumes you already know:
- Basic Salesforce navigation and how to open Setup.
- The difference between standard and custom objects, records, and fields.
- What profiles and permission sets are, at a high level.
- Basic SOQL, if you want to follow the optional query at the end.
The three questions Salesforce asks
Access in Salesforce is not one switch. It is a stack of separate checks, and each check answers a different question.
- Can this user work with this kind of data at all? This is object-level security. It is controlled by profiles and permission sets.
- Which fields on that object can this user see or edit? This is field-level security. It is also controlled by profiles and permission sets.
- Which individual records can this user see or edit? This is record-level access. It is controlled by ownership, org-wide defaults, the role hierarchy, sharing rules, manual sharing, and teams.
This tutorial is about the third question. The first two still matter, because they act as gates in front of it.
How the layers work together
Think of the checks as filters applied one after another. A user must pass the object check before the record check even matters.
- Object permissions say which operations a user may perform on an object: Read, Create, Edit, Delete, plus View All and Modify All.
- Field-level security hides or locks individual fields. A user who can open a record may still see a blank or missing field.
- Record access decides which rows of the object the user can open.
The two permission layers are about what a user may do. Record access is about which rows the user may do it to. If a user has Read on Invoices but no record access to a particular invoice, that invoice does not appear in list views, reports, or search for that user.
Permissions can only narrow record access in one direction
Object permissions and record access combine in a specific way. Neither one can grant what the other withholds, with two exceptions.
| Situation | Result |
|---|---|
| Has object Read, has record access | User sees the record. |
| Has object Read, no record access | User does not see the record. |
| No object Read, has record access | User does not see the record. |
| Has View All or Modify All on the object | User sees every record of that object, regardless of sharing. |
| Has View All Data or Modify All Data | User sees every record in the org, regardless of sharing. |
The last two rows are the exceptions. Those permissions bypass record-level sharing completely. Grant them sparingly, since no sharing rule can restrict a user who holds them.
The record-access layers in order
Record-level access is built from the most restrictive setting outward. You start closed and open access in steps.
- Record ownership. The owner of a record can always see and edit it. Ownership is the starting point.
- Org-wide defaults (OWD). This is the baseline level of access for each object, for users who do not own a record. Typical values are Private, Public Read Only, and Public Read/Write. It is the most restrictive setting in the system.
- Role hierarchy. Users higher in the hierarchy can get access to records owned by users below them. This opens access upward.
- Sharing rules. Automatic exceptions that extend access to groups, roles, or users, based on record owner or on field values.
- Manual sharing. A user with sufficient access shares one specific record with another user or group.
- Teams. Account teams, opportunity teams, and case teams give named people access to a specific record for a specific purpose.
The central rule: access is additive
The most important idea in this tutorial is that every layer after the org-wide default can only add access. It cannot take access away.
- If OWD is Private, nothing grants a non-owner access until a mechanism opens it.
- If OWD is Public Read Only, a sharing rule can raise some users to Read/Write. It cannot lower anyone below Read Only.
- If any one mechanism gives a user access, the user has access. Salesforce takes the most permissive result.
This has a design consequence. You cannot "deny" a user on one record while leaving the object open to everyone else. To restrict access, you must make the OWD more restrictive and then open access selectively. That is why the OWD is described as the most restrictive baseline, and why it is the first thing you decide for each object.
A worked example
Suppose a custom object, Invoice, has an OWD of Private. Three users matter:
- Dana owns invoice INV-100. She sits in the Sales Rep role.
- Priya is Dana's manager. She sits in the Sales Manager role, above Sales Rep.
- Marco is a finance analyst in an unrelated role.
Here is what each user can do with INV-100 at each stage:
| Stage | Dana | Priya | Marco |
|---|---|---|---|
| Invoice created, OWD Private | Full access as owner | Access through the role hierarchy, if Grant Access Using Hierarchies is on | None |
| A sharing rule shares overdue invoices with the Finance group, and Marco belongs to it | Full access | Access | Read access, if the invoice matches the rule |
| Dana manually shares INV-100 with Marco as Read/Write | Full access | Access | Read/Write |
In the last row, Marco has two sources of access, and Salesforce gives him the higher level: Read/Write.
Seeing the layers as data
Most of these mechanisms are stored as rows in a share table for the object. A custom object named Invoice has a table called Invoice__Share. Each row records who has access, how much, and why. The "why" is the row cause.
SELECT Id, ParentId, UserOrGroupId, AccessLevel, RowCause
FROM Invoice__Share
WHERE ParentId = '<invoice record Id>'Replace the placeholder with a real record Id. The result shows the owner row and any rows created by sharing rules or manual shares. Not every mechanism appears here. Access that comes from the role hierarchy and from OWD is calculated rather than stored per record, so you will not see a row for a manager who sees a record only through the hierarchy. Later chapters return to this query and explain each row cause.
Common mistakes at this stage
- Confusing permission with access. Giving a profile Read on an object does not let it see all records. It only allows the user to see records that record access already allows.
- Opening the OWD too far. Setting OWD to Public Read/Write to fix one access problem exposes every record of that object to every user. You cannot narrow it with other mechanisms.
- Forgetting field-level security. A user may reach a record but still not see a field. This is a separate setting and is not fixed by sharing.
- Using View All or Modify All as a shortcut. These permissions override all sharing, which makes the sharing model hard to reason about later.
- Expecting a sharing rule to deny. Rules add access only.
What comes next
The next chapters follow the order of the layers. You begin with record ownership, then set org-wide defaults, then open access with the role hierarchy, public groups, rules, manual shares, and teams.
Exercise
An Invoice object has an OWD of Private. A user has Read permission on Invoice through a profile, is not the owner of INV-200, is not in the owner's role hierarchy line, and no rule, manual share, or team applies. Can the user see INV-200? Then say what single change, short of changing OWD, could give the user Read access to only that record.
Show answer
No. Object Read permission only allows the user to work with Invoice records they can already reach, and no layer grants record access here. A manual share of INV-200 with that user at Read level would give access to only that record. A sharing rule would also work, but it would affect every record matching the rule, not just this one.
Exercise
Why is it impossible to use a sharing rule to stop one user from seeing a record when OWD is Public Read Only?
Show answer
Sharing rules and the other mechanisms after OWD can only add access. OWD sets the minimum that every user already has, so no rule can lower it. To restrict that user, the OWD would have to be made Private, and access then opened selectively for everyone else.