Sub topic 4
What Field-Level Security Controls: Read and Edit
This chapter assumes you know Salesforce objects, fields, records, and users. It also assumes you have used Setup and the Object Manager, and that you can read basic Apex and SOQL. Earlier chapters covered the security layers, profiles, permission sets, and object permissions. This chapter defines what field-level security (FLS) itself controls.
The two settings: Read and Edit
Field-level security is a per-field access rule. For each field, a user either has or lacks two permissions:
- Read: the user can see the field's value.
- Edit: the user can change the field's value. Edit requires Read, so Salesforce never grants Edit without Read.
That gives three effective states for any field:
| State | Read | Edit | What the user experiences |
|---|---|---|---|
| Hidden | No | No | The field is absent from record pages, reports, list views, and API results. |
| Read-only | Yes | No | The user sees the value but cannot change it. |
| Editable | Yes | Yes | The user can see and change the value. |
The state "Edit without Read" does not exist. If you clear Read on a field in Setup, Edit is cleared too.
How FLS relates to other controls
FLS answers one question: may this user see or change this field? It does not answer whether the user can reach the record or the object. Three controls apply in sequence.
- Object permissions (CRUD) decide whether the user can create, read, edit, or delete records of the object at all.
- Record access (sharing, ownership, role hierarchy) decides which records the user can reach.
- FLS decides which fields the user can see or edit on those records.
All three must allow the action. A user with Read on Account.AnnualRevenue but no Read on the Account object sees nothing. A user with full object access and Read on the field still cannot see the field on an account they have no sharing access to.
How access is calculated
A user's FLS is the union of all permissions granted to them. The user's profile grants a baseline. Each assigned permission set (directly or through a permission set group) can add more. Permission sets and groups can only add access. They cannot remove access that the profile grants.
Two consequences follow:
- If any assigned container grants Read on a field, the user has Read.
- If any assigned container grants Edit on a field, the user has Edit.
To take access away, remove it from every container that grants it. A common error is to clear the field on one permission set and then be surprised that the user can still see it, because the profile or another permission set still grants it. This is why least-privilege designs keep profiles minimal and add access with permission sets.
Muting permission sets inside a permission set group are the exception. A muting permission set can switch off permissions that other permission sets in the same group grant. It does not reduce what the user's profile grants.
Fields that FLS does not control
Not every field can be secured. Some fields are always visible and cannot be hidden:
- Standard system fields such as
Id,CreatedDate,CreatedById,LastModifiedDate, andLastModifiedById. - The name field of an object, on most standard and custom objects.
- Fields that are required at the database level in ways that block hiding, such as the master-detail relationship field on a detail object.
Some fields are read-only for everyone regardless of FLS, for example formula fields, roll-up summary fields, and auto-number fields. For these, Setup shows only a Read checkbox. Granting Read on a formula field does not grant access to the fields it references. A formula that references a field the user cannot read still returns its computed value.
Edit access is not the same as updateable
Edit in FLS is one of several conditions for changing a value. A user may have Edit on a field and still fail to change it, because:
- The user lacks Edit permission on the object.
- The user lacks edit access to the specific record through sharing.
- The field is a system-managed or calculated field.
- A validation rule, a trigger, or a locked record (for example one in an approval process) blocks the change.
The Apex method isUpdateable() reflects the FLS and field-type conditions for the current user. It does not predict validation rules or record-level restrictions.
Where you see the effect
The effect of FLS appears in a few common situations:
- A hidden field is missing from record detail pages, even if the page layout includes it.
- A read-only field appears as plain text in edit mode.
- Reports, list views, and dashboards omit fields the user cannot read. A report filtered on an unreadable field can return unexpected results or an error.
- API calls such as SOQL through REST or SOAP, made as that user, reject queries that name an unreadable field.
Later chapters cover each of these in detail. The point here is that FLS is enforced by the platform for these entry points, but Apex code runs differently, as shown below.
FLS in Apex, briefly
By default, Apex runs in system mode. It reads and writes fields without checking the running user's FLS. A query for AnnualRevenue succeeds for a user who cannot see that field in the UI. Later chapters explain how to enforce FLS in code. As a preview, this query enforces it:
List<Account> accounts = [
SELECT Id, Name, AnnualRevenue
FROM Account
WHERE Industry = 'Technology'
WITH USER_MODE
];If the user cannot read AnnualRevenue, this query throws an exception instead of returning the value.
Reading FLS from metadata
FLS is stored as fieldPermissions entries. Each entry names a field and sets its readable and editable flags. This permission set grants Read and Edit on one custom field:
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Account Notes Access</label>
<fieldPermissions>
<editable>true</editable>
<field>Account.Internal_Notes__c</field>
<readable>true</readable>
</fieldPermissions>
</PermissionSet>An entry with readable set to true and editable set to false produces the read-only state. Setting editable to true with readable set to false is invalid, which matches the rule that Edit requires Read.
Common errors
- Assuming a page layout secures a field. Removing a field from a layout hides it on that page only. A user with Read can still reach it through reports, the API, and other layouts.
- Removing access from one container only. The user keeps access from any other profile or permission set that grants it.
- Assuming Apex checks FLS. System-mode code ignores it unless you enforce it.
- Forgetting object permissions. Field access does nothing without Read on the object.
- Treating formula output as protected. A formula can reveal a hidden field's data.
Exercise
A user's profile grants no access to Account.InternalNotes_c. The user is assigned two permission sets. The first grants Read only on the field. The second grants Read and Edit. Can the user edit the field in the UI, assuming object and record access allow it? Then, you remove the field from the second permission set. What is the user's access now?
Show answer
Yes, the user can edit the field, because access is the union of all containers and the second permission set grants Edit. After you remove the field from the second permission set, the user has Read only, because the first permission set still grants Read. The field appears as read-only, and the user cannot change its value.
Exercise
Why can a user who has no Read access to a field still see data from it on a record? Give one example.
Show answer
A formula field can reference the hidden field. FLS on the formula field and FLS on the referenced field are independent, so a user with Read on the formula field sees the computed value that includes the hidden field's data. System-mode Apex that returns the field to the client is another example.