Sub topic 3
Object permissions and why they come first
This chapter assumes you know what objects, fields, records, and users are in Salesforce. It also assumes you can find Setup and the Object Manager, and that you can read basic Apex and SOQL. The chapter covers object permissions, often called CRUD. It explains how they gate field-level security (FLS), and it lists the errors people make when the two interact.
What object permissions are
Object permissions decide what a user can do with an object as a whole. There are six of them:
| Permission | Letter | What it allows |
|---|---|---|
| Read | R | View records of the object |
| Create | C | Create new records |
| Edit | E | Change existing records |
| Delete | D | Delete records |
| View All | See every record of the object, ignoring sharing | |
| Modify All | Read, edit, delete, and transfer every record, ignoring sharing |
The first four make up the name CRUD (Create, Read, Update, Delete). Salesforce labels the update permission "Edit" in Setup. View All and Modify All are record-level overrides that you grant at the object level. They are the reason object permissions and record sharing are not fully independent.
A user needs object access before any field access can matter. A field belongs to an object, so a user who cannot read the object has nothing to read the field from.
The gating rule
FLS sits underneath object permissions. A user's effective access to a field is the narrower of two things: the object permission and the field permission.
| Object permission | Field permission | Effective result |
|---|---|---|
| No Read | Read | No access. The user cannot see the object, so the field is unreachable. |
| Read | No Read | The user sees the record but not this field. |
| Read, no Edit | Edit | The user cannot edit. Object access is read-only. |
| Read, Edit | Read only | The user can edit the record but not this field. |
| Read, Edit | Edit | The user can edit the field, subject to record sharing. |
The third row is the one people miss. A field marked Edit in a permission set does not make an object editable. The field setting never widens what the object permission allows.
The diagram shows the three layers. Object permissions come first, record access comes second, and FLS decides which fields of an accessible record the user sees. Record sharing is covered in other material. Here the point is the order: the field check happens last, so a failure earlier means the field setting is never consulted.
Where object permissions come from
Object permissions are granted through the same containers as FLS: profiles and permission sets. Access is additive across all of them. If a profile grants Read on Account and a permission set grants Edit on Account, the user has both. Nothing in a permission set can remove an access that the profile grants.
This is the same for fields. If any of the user's profile or permission sets gives Read on a field, the user has Read on that field. To take access away, you must remove it from every source that grants it.
In Setup you configure object permissions in these places:
- A profile's Object Settings page lists each object with its CRUD flags and its field permissions.
- A permission set's Object Settings page works the same way.
- The Field Accessibility page (Setup, then Security) shows the effective access to one field across profiles, which is useful for checking your work.
Because field settings live on the same page as object settings, Salesforce's own interface reflects the dependency. When you grant Read on an object, you can then grant field access beneath it. When you remove Read from an object, the field settings below it stop mattering.
Dependencies that Salesforce enforces for you
Salesforce enforces some dependencies automatically when you save a permission set or profile.
- Edit requires Read. You cannot grant Edit without Read on the same object.
- Delete requires Read and Edit.
- View All requires Read.
- Modify All requires Read, Edit, Delete, and View All.
- On fields, Edit requires Read. Selecting Edit selects Read for you, and clearing Read clears Edit.
These rules apply to fields in the same way as to objects. A field cannot be editable but unreadable.
Seeing the difference in metadata
In metadata, object permissions and field permissions are separate elements in the same permission set. The object permission is an objectPermissions entry, and the field permission is a fieldPermissions entry.
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Account Notes Access</label>
<objectPermissions>
<allowCreate>false</allowCreate>
<allowDelete>false</allowDelete>
<allowEdit>true</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>false</modifyAllRecords>
<object>Account</object>
<viewAllRecords>false</viewAllRecords>
</objectPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Account.Internal_Notes__c</field>
<readable>true</readable>
</fieldPermissions>
</PermissionSet>This permission set lets a user read and edit existing Accounts, and read and edit Internal_Notes__c on them. The user cannot create or delete Accounts. If you removed the objectPermissions block, the fieldPermissions entry would still be present, but the user would have no Account access, so it would have no effect.
How Apex checks object permissions
Apex has the same two kinds of checks, and they follow the same order. Describe methods test the object first and then the field:
if (Schema.sObjectType.Account.isUpdateable()
&& Schema.sObjectType.Account.fields.AnnualRevenue.isUpdateable()) {
acc.AnnualRevenue = 2000000;
update acc;
}The first call checks the object-level Edit permission. The second checks the field-level Edit permission. Checking only the field is incomplete, because a user with field Edit but no object Edit would pass the field check and then fail at the update.
User mode does both checks for you. In the next example, the insert fails if the user lacks Create on Account or Edit on any assigned field:
Account acc = new Account(Name = 'Acme', AnnualRevenue = 1000000);
Database.insert(acc, AccessLevel.USER_MODE);Later chapters cover these tools in detail. For now, remember that "enforce FLS" in code always means enforcing object permissions as well.
Common errors
- Granting field access without object access. An admin adds a field to a permission set, but the user still cannot see it. The user has no Read on the object. Check object permissions first.
- Expecting field Edit to grant object Edit. The field setting is capped by the object setting.
- Using View All or Modify All as a shortcut. These skip record sharing for the whole object. They do not change FLS, but they greatly widen who can see records, so grant them rarely.
- Removing access from one source only. Access is additive. If a profile still grants Read, a new permission set that omits it changes nothing.
- Testing as an admin. System Administrators usually have Modify All Data, which overrides object permissions. A test as an admin proves nothing about a restricted user.
- Debugging fields before objects. When a user reports a missing field, check in this order: object permission, record access, then FLS.
Why this order matters for design
Designing from the object down keeps your permission model small. Decide first which users need which objects, and grant those with CRUD flags. Then grant fields beneath each object, giving only what each role needs. If you start with fields, you tend to add field access to permission sets that have no object access behind them, and the work does nothing.
This order also helps when you audit. For each object, list who holds Read. Only those users can have any field access. That group is the upper bound for the field review, and it is usually much smaller than the full user list.
Exercise
A user has a permission set that grants Edit on the field Account.InternalNotesc. Their profile gives Read on Account, with no Edit, Create, or Delete. No other permission set applies. Can the user change InternalNotes__c on an Account? Explain, and name the single change that would fix it.
Show answer
No. Object permissions come first and cap field access. The user has only Read on Account, so the field's Edit setting has no effect. Granting Edit on the Account object, for example in a permission set, would let the field's Edit permission take effect, subject to record sharing.
Exercise
Write the order of checks Salesforce applies when a user opens a record and asks to see one field. Then say which check you would look at first if the user reports that an entire record is missing but other records of the same object show.
Show answer
The order is object permission, then record access (sharing or View All), then field-level security. If one record is missing while others show, the object permission is fine, so look at record access, meaning sharing, ownership, or View All.