Sub topic 8
Required fields and how they interact with FLS
This chapter assumes you know what Read and Edit mean for field-level security (FLS) and how to set them on a profile or permission set. It covers what happens when a field is also marked required.
Three kinds of "required"
Salesforce uses the word "required" in three places. Each one interacts with FLS differently.
| Kind | Where it is set | Enforced in | Interaction with FLS |
|---|---|---|---|
| Universally required | Field definition (Object Manager) | UI, API, Apex, imports, flows | FLS cannot hide it. Read and Edit are always on. |
| Required on a page layout | Page layout | Record pages in the UI only | If FLS hides the field, the field is not on the user's page, so it is not required for them. |
| Validation rule | Validation rule formula | Everywhere the record is saved | Independent of FLS. It evaluates the data, not field access. |
Universally required fields
When you mark a field as required in its definition, every save must supply a value. This includes saves from the API, Apex, Data Loader, and flows. A required field is always readable and editable, so you cannot remove its access with a profile or permission set. In the FLS screen, the checkboxes for such a field appear checked and locked. Standard fields such as Account.Name and master-detail relationship fields behave the same way.
Required fields also affect your Apex. Even in user mode, an insert that omits one fails:
Account acc = new Account(); // Name is required and missing
try {
Database.insert(acc, AccessLevel.USER_MODE);
} catch (DmlException e) {
System.debug(e.getDmlStatusCode(0)); // REQUIRED_FIELD_MISSING
}The error is a data error, not a permission error. User mode adds FLS checks on top of the platform's normal data rules.
Layout-required fields and the FLS gap
A field that is required only on a page layout is a UI rule. Two things follow from that:
- A user without Edit access to the field never sees it on the layout. They can save the record without a value.
- Apex, the API, and integrations ignore layout requirements entirely.
If a value must always exist, don't rely on the layout. Use the universal required setting, or a validation rule if the requirement depends on other data.
Design implications
The main consequence is that a universally required field cannot hold sensitive data that some users must not see. If you mark Internal_Notes__c as required, every user who can create the record must see and fill it in. Choose one of these designs:
- Leave the field optional and enforce presence with a validation rule that applies only to the roles that should enter it.
- Use a layout requirement for the users who have Edit access, accepting that other paths bypass it.
- Move the sensitive data to a related object that has its own object permissions.
Troubleshooting
- Users can't create records after you add a required field: Check whether the field's data is supplied by integrations and automations. They need a value for it too.
- A field shows as required for some users and not others: This is the layout requirement combined with FLS. The users who don't see the field have no Edit access.
- FLS checkboxes are greyed out and checked: The field is universally required.
Exercise
A custom field Region__c is required only on the Account page layout. A user whose profile has no Edit access to Region__c creates an Account in the UI. Another integration user inserts an Account through the API without a value. What happens in each case?
Show answer
Both saves succeed. The UI user does not see the field, so the layout requirement does not apply to them. The API ignores layout requirements. Only a universal required setting, or a validation rule, would block both saves.