Sub topic 6
Where FLS applies: UI, reports, list views, search, and APIs
This chapter assumes you know what Read and Edit field access mean and how profiles and permission sets grant them. It also assumes you can write basic SOQL and Apex. Here you will learn which Salesforce features enforce field-level security (FLS) on their own, and which ones leave enforcement to you.
The short version
Salesforce enforces FLS in its standard user interface, reports, list views, search, and in its APIs. Apex code is the main exception. Code that runs in system mode ignores FLS unless you ask for it. The next chapters cover that case.
The table summarizes the behavior.
| Surface | FLS enforced automatically? | What the user sees when a field is hidden |
|---|---|---|
| Record detail and edit pages | Yes | The field does not appear |
| List views | Yes | The column or filter option is unavailable |
| Reports and dashboards | Yes | The field is missing from the report type's field list |
| Global search and lookup search | Yes | Hidden fields are not searched or shown |
| REST and SOAP API | Yes | The field is missing from describe results, and queries on it fail |
| Data Loader, Bulk API | Yes | Same as the API, because these tools call it |
| Apex in system mode | No | Code can read and write the field |
| Apex in user mode | Yes | An exception is thrown |
Standard user interface
On record pages, the platform checks FLS for each field before it draws it. A field with no Read access is left out of the page. A field with Read but no Edit access is shown as read-only. Inline editing follows the same rule.
This is separate from the page layout. A field can be on the layout and still be invisible to a user, because the user's FLS removes it. The reverse does not work. If a field is off the layout, FLS may still allow the user to reach it through the API or a report. The chapter on page layouts covers this difference.
List views and filters
In list views, a user cannot add a column for a field they cannot read. Hidden fields also cannot be used as filter criteria.
An existing list view can reference a field that a user later loses access to. In that case, the platform drops the column for that user. It does not fail the whole view. The list view definition itself is unchanged for other users.
Reports and dashboards
Reports run with the permissions of the person viewing them, and the field list in the report builder only shows fields that person can read. If a report includes a field and a viewer lacks Read access, that viewer does not get the field's values.
Dashboards behave differently. A dashboard component is driven by a source report, and that report runs as a chosen running user. Every viewer sees data computed from the running user's access. So a dashboard can show aggregated values from a field that a viewer cannot read directly.
Search
Global search and lookup search honor FLS. A user cannot find a record by matching text in a field they cannot read, and search results do not display hidden fields. This stops users from inferring hidden values by trying search terms.
SOSL queries in Apex follow the Apex rules instead. In system mode, SOSL can match fields the running user cannot read. Use WITH USER_MODE in SOSL when the results go to the user.
APIs
The REST API, SOAP API, Bulk API, and tools built on them (such as Data Loader and Workbench) enforce FLS for the authenticated user.
- A describe call returns only the fields the user can see.
- A query that names a field the user cannot read fails with an
INVALID_FIELDerror. - A
SELECT FIELDS(ALL)query returns only the fields the user can read. - An insert or update that includes a field without Edit access is rejected or the field is ignored, depending on the API and the operation.
An error such as the following shows what a blocked query looks like in the REST API:
[
{
"message": "\nSELECT Id, Internal_Notes__c FROM Account\n ^\nERROR at Row:1:Column:12\nNo such column 'Internal_Notes__c' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.",
"errorCode": "INVALID_FIELD"
}
]Notice that the message says the column does not exist. The platform does not confirm that a field exists when the user has no access to it.
Where FLS does not apply by itself
Several things run without checking FLS for the current user.
- Apex in system mode. Classes, triggers, and anonymous Apex read and write any field unless you opt in to user mode.
- Flows in system context. A flow set to run in system context ignores FLS. A flow run in user context respects it.
- Formula fields and roll-up summary fields. A formula can reference a field the viewer cannot read. The viewer can still see the formula result if they can read the formula field itself.
- Validation rules, workflow rules, and duplicate rules. These evaluate with all field values, whatever the user can see.
- Sharing-based visibility. FLS does not grant or remove record access. A user who cannot see a record cannot see its fields, whatever the FLS says.
The formula case deserves attention. A formula field has its own FLS. If you expose a formula that derives from a sensitive field, the sensitive value may leak through it. Set the formula field's access to match the sensitivity of its inputs.
How the layers combine
A user sees a field value only when every layer allows it. The diagram shows the order of checks for a query from the standard UI or API.
Checking what a user can see
You can confirm the effective access for a user in two ways.
- In Setup, open the field's Set Field-Level Security page to see which profiles have access. Permission sets are shown in the field's access view too.
- Use Field Accessibility (under Security in Setup) to view access by field, profile, or record type.
For one specific user, log in as that user with the Login action, if your org allows it, and look at the record. This is the most direct test.
You can also check from code. The next snippet queries field permission records to find which permission sets and profiles grant Read access to a field.
List<FieldPermissions> perms = [
SELECT Parent.Label, Parent.IsOwnedByProfile, PermissionsRead, PermissionsEdit
FROM FieldPermissions
WHERE SobjectType = 'Account'
AND Field = 'Account.AnnualRevenue'
AND PermissionsRead = true
];
for (FieldPermissions fp : perms) {
System.debug(fp.Parent.Label + ' | edit: ' + fp.PermissionsEdit);
}Each result is the access granted by one profile or permission set. Combine the results across all assignments to find a user's effective access. A user gets the most permissive result across all their profile and permission sets.
Common mistakes
- Assuming dashboards use the viewer's access. They use the running user's access unless configured otherwise.
- Treating "not on the layout" as secured. Users can still reach the field through reports, the API, and search.
- Forgetting formula fields. A formula copies the value of a protected field to a place with different access.
- Assuming Apex checks FLS. A
@AuraEnabledmethod that returns an unfiltered query result sends hidden fields to the browser. - Testing only as an administrator. Admins usually have access to everything, so a test as admin hides every FLS gap.
Exercise
A sales manager can read the Account object and a specific account record. Their profile has no Read access on Account.AnnualRevenue. A dashboard component shows total AnnualRevenue by industry, and its running user is an administrator. Can the manager see the totals? Can the manager add AnnualRevenue as a column in a list view? Explain each answer.
Show answer
Yes to the dashboard. The dashboard runs its source report as the running user, who is an administrator with access to the field, so the manager sees aggregated values even without Read access. No to the list view. List views apply the manager's own FLS, so AnnualRevenue is not available as a column or filter.
Exercise
A developer writes an @AuraEnabled method that runs "SELECT Id, Name, InternalNotesc FROM Account" in system mode and returns the records to a component. The calling user has no Read access on InternalNotes__c. What happens, and how would you change the query so FLS applies?
Show answer
The query succeeds and the notes are sent to the browser, because system mode does not enforce FLS. Add WITH USER_MODE to the query. Then Salesforce throws an exception when the user cannot read the field. You can also pass the results through Security.stripInaccessible to remove the field instead of failing.