Sub topic 1
Where Field-Level Security Fits in the Salesforce Security Model
Salesforce does not use a single access switch. It checks several independent layers, and a user needs to pass each one to see or change a value. Field-level security (FLS) is one of these layers. This chapter shows where FLS sits, what it does not control, and how it combines with the other layers. Later chapters cover how to set it and enforce it.
Prerequisites
This chapter assumes you already know:
- The basic data model: objects, fields, records, and users.
- How to open Setup and the Object Manager.
- Basic Apex and SOQL syntax. You need it only for the short example near the end.
The layers of access
Salesforce answers "can this user see this value?" by asking a series of questions. Each question belongs to a different layer, and each layer is configured in a different place.
| Layer | Question it answers | Main tools |
|---|---|---|
| Org access | Can the user sign in at all? | Login hours, IP ranges, MFA, user status |
| Object permissions (CRUD) | Can the user create, read, edit, or delete records of this object? | Profiles, permission sets |
| Field-level security | Can the user read or edit this field? | Profiles, permission sets |
| Record access | Can the user see this particular record? | Org-wide defaults, role hierarchy, sharing rules, teams, manual sharing |
The layers are separate on purpose. Object permissions and FLS describe what kinds of data a user may touch. Record access describes which rows they may touch. Mixing these up is the most common source of confusion.
The diagram orders the checks for explanation. Salesforce does not expose this as a pipeline you can inspect. What matters is that failing any one layer is enough to block access, and passing one layer never grants another.
Object permissions come first
Object permissions are often called CRUD: Create, Read, Edit, Delete. They are set per object on a profile or permission set. A user with no Read permission on Account cannot see any Account data, whatever the field settings say.
This gives a rule that is easy to forget: FLS can only narrow access that the object permission already allows. It never widens it.
- Field Read without object Read: the user cannot read the field, because they cannot reach the object.
- Field Edit without object Edit: the user cannot edit the field, because they cannot edit records of that object.
- Object Edit with field Read only: the user can edit the record, but that field stays read-only.
What field-level security controls
FLS applies to one field on one object and has two settings:
- Read: the user can see the field's value.
- Edit: the user can change the field's value. Edit implies Read, so you cannot grant Edit without Read.
FLS is granted through profiles and permission sets. Permissions are additive. If a profile gives no access to a field and a permission set assigned to the same user gives Read, the user has Read. Salesforce combines all of a user's profile and permission set grants, so the most permissive result wins. You cannot take a field away with a second permission set, unless you use a muting permission set inside a permission set group. A later chapter covers that.
FLS does not decide which records a user sees. It does not hide a field on one record while showing it on another. If a user can read the field, they can read it on every record they can access.
Record access is a separate axis
Record access answers "which rows?" It is controlled by:
- Org-wide defaults, which set the baseline for each object (for example Private or Public Read Only).
- The role hierarchy, which lets managers see their reports' records.
- Sharing rules, teams, and manual sharing, which open access further.
Record access can only open access above the org-wide default. It never closes access that object permissions have already granted, and it has no effect on fields. Two users can see the same record and still see different fields, because their FLS differs.
A worked example
Suppose the Account object has a custom field Internal_Notes__c. Three users can all see the same Account record:
| User | Object Read on Account | Record shared | FLS on `Internal_Notes__c` | Result |
|---|---|---|---|---|
| Sales rep | Yes | Yes (owner) | No access | Sees the account, not the notes |
| Support agent | Yes | Yes (sharing rule) | Read | Sees the notes, cannot change them |
| Account manager | Yes | Yes (owner) | Read and Edit | Sees and edits the notes |
| Contractor | No | Not applicable | Read | Sees nothing, because the object check fails first |
The contractor row shows that granting field Read does not help without object Read. The first three rows show that identical record access can still give different field access.
Where this matters for code
Standard Salesforce screens, reports, and APIs check FLS for you. Apex does not. By default, Apex runs in system mode, which ignores the running user's object permissions and FLS. The with sharing keyword changes only record access. It does not change field access.
public with sharing class AccountNotesService {
// with sharing limits which records are returned.
// It does not stop this query from reading fields the user cannot see.
public static List<Account> getTechAccounts() {
return [
SELECT Id, Name, Internal_Notes__c
FROM Account
WHERE Industry = 'Technology'
];
}
}If the sales rep above calls this method from a Lightning component, the result includes Internal_Notes__c, even though FLS hides it from that rep. This gap is why later chapters on user mode, Security.stripInaccessible, and describe checks exist.
Common errors
- Treating sharing as field security. Making a record private does not hide any of its fields from users who can see it. Only FLS limits fields.
- Treating FLS as record security. Hiding a field does not restrict which records are visible.
- Assuming
with sharingenforces FLS. It enforces record sharing only. - Granting field access without object access. The grant has no effect until the object permission exists.
- Looking for the "missing" permission in only one place. A user's effective access is the union of their profile and every assigned permission set. Check all of them.
What comes next
The following chapters take each piece in turn: profiles and permission sets as containers, object permissions, the Read and Edit settings in Setup, where FLS is enforced, and finally how to enforce it in Apex and test it.
Exercise
A user has Read access to the Opportunity object and a sharing rule that gives them access to a specific Opportunity record. Their profile and permission sets give no FLS on the Opportunity field Discount__c. What does the user see on that record, and which layer causes it?
Show answer
The user sees the Opportunity record and its other readable fields, but not Discount__c. Object permission and record access both pass, so the record is visible. Field-level security blocks only that field, because no profile or permission set grants Read on it.
Exercise
A developer writes a with sharing Apex class that queries Account.AnnualRevenue and returns it to a Lightning component. A user without FLS Read on AnnualRevenue runs it. Does the user get the value? Why?
Show answer
Yes, the value is returned. Apex runs in system mode by default, and with sharing enforces only record-level sharing. It does not enforce object permissions or FLS, so the developer must enforce field access explicitly in code.