Sub topic 7
Page layouts versus FLS: hiding is not securing
This chapter assumes you know how to open Object Manager, can assign a profile or permission set to a user, and can read a basic SOQL query. It builds on the previous chapters on Read and Edit access. Its goal is to show why removing a field from a page layout does not protect the data in it.
What a page layout actually does
A page layout controls how a record page looks. It decides:
- Which fields appear, and in which sections and columns.
- Which fields are marked Read-Only or Required on that layout.
- Which buttons, quick actions, and related lists appear.
Layouts are assigned by profile, and optionally by record type. A sales profile can see one arrangement of the Account page while a support profile sees another.
A layout is a presentation setting. It applies only to the pages that render it. It does not change what the user is allowed to do with the data.
What FLS does differently
Field-level security (FLS) is an access rule on the field itself. It is attached to the profile or permission set, and the platform checks it wherever the field is used. That includes the record page, and it also includes reports, list views, search, and API calls.
The two controls answer different questions:
| Question | Page layout | FLS |
|---|---|---|
| Is this field a security boundary? | No | Yes |
| What does it describe? | Placement, read-only and required flags on one page | Whether the user can read or edit the field |
| Where is it assigned? | Profile and record type | Profile and permission sets |
| Does it affect API and SOQL? | No | Yes |
The rule when both apply
When a record page renders a field, the platform applies the more restrictive of the two settings. FLS always wins over the layout.
- Field on the layout, FLS has no Read: the field does not appear.
- Field on the layout as editable, FLS is Read only: the field appears but is not editable.
- Field not on the layout, FLS has Read and Edit: the field does not appear on the page, but the user is still permitted to read and edit it elsewhere.
- Field on the layout as Read-Only, FLS has Edit: the field is read-only on that page. The Edit permission is still available outside that page.
The third and fourth cases are the dangerous ones. The layout hides or locks the field in one place. The user's permission to the field is unchanged.
Demonstrating the gap
Suppose Internal_Notes__c on Account is removed from every layout, and the sales profile still has Read access to it. A user on that profile will not see the field on the Account page. They can still query it with the CLI, Data Loader, or any API client.
sf data query \
--query "SELECT Id, Name, Internal_Notes__c FROM Account LIMIT 5" \
--target-org myOrgThe query succeeds and returns the notes. If the profile had no Read access, the same query would fail with an error such as No such column 'Internal_Notes__c' on entity 'Account'. The platform reports a field the user cannot read as if it did not exist.
The same effect applies to:
- Reports and report builder, which can add any field the user can read.
- List view columns and filters.
- Search results where the field is searchable.
- Integrations and mobile apps that call the API directly.
- Flows that run in user context and read the field.
How layout settings look in metadata
Layouts are stored as Layout metadata. The behavior value on each item is where Read-Only and Required are set.
<?xml version="1.0" encoding="UTF-8"?>
<Layout xmlns="http://soap.sforce.com/2006/04/metadata">
<layoutSections>
<label>Account Information</label>
<style>TwoColumnsTopToBottom</style>
<layoutColumns>
<layoutItems>
<behavior>Required</behavior>
<field>Name</field>
</layoutItems>
<layoutItems>
<behavior>Readonly</behavior>
<field>AnnualRevenue</field>
</layoutItems>
</layoutColumns>
<layoutColumns/>
</layoutSections>
</Layout>Nothing in this file mentions a user, a permission, or a sharing rule. A Readonly behavior here says only that this page shows the field without an input box. Compare it with the fieldPermissions entry from the previous chapter, which grants or removes access for a permission set.
Lightning record pages and Dynamic Forms
Lightning record pages add a second presentation layer. With Dynamic Forms, you place fields directly on the page and set visibility filters, for example "show only when Type equals Customer". These filters can use user attributes such as profile or permission.
Treat them the same way as layouts. A visibility filter decides whether a component renders. It does not decide whether the user can read the data behind it. FLS is still checked for each field, so a field with no Read access stays hidden even where the filter says to show it. A field with Read access that a filter hides is still readable through every other path.
Common mistakes
- Using the layout to hide sensitive fields. Salary, tax IDs, and internal ratings need FLS removal. A layout change only tidies the page.
- Marking a field Read-Only on the layout to stop edits. An API client or an import can still write to it if the user has Edit. Remove Edit in FLS.
- Auditing only the layouts. A review of what users can see on the page misses what they can reach through reports and the API. Review FLS on profiles and permission sets.
- Assuming a shared layout implies shared access. Two profiles can use the same layout and have different FLS, and the pages will then render differently.
- Testing only in the UI. A field that looks protected in the browser may still be returned by a query. Test with an API call as the target user.
When layouts are the right tool
Layouts are still worth using. They reduce clutter, order fields to match a business process, and make required fields obvious. Use a layout to keep a page usable. Use FLS to decide who is allowed to touch the data. A good design uses both: FLS grants the minimum access, and the layout presents only the fields that users with that access need.
Exercise
The Account layout for the Support profile has Internal_Notes__c removed. Support users still have Read and Edit on the field. Name two ways they could still read it and what change would actually protect it.
Show answer
They can read it in a report or list view column, or through an API query such as SELECT InternalNotes_c FROM Account. Search and integrations are also valid answers. To protect it, remove Read (and Edit) for the field from the Support profile and any permission sets that grant it, because FLS is what the platform enforces on those paths.
Exercise
A field is marked Required on a page layout, but a user's FLS gives them Read only. What happens to the field on that user's record page, and which setting decides?
Show answer
The user cannot edit the field on the page, because FLS overrides the layout. The Required flag does not make the field editable for that user. The more restrictive setting, here Read only from FLS, decides what the user can do.