Sub topic 3
Object permissions and why they come first
This chapter assumes you know what objects, fields, and records are, can find an object in Object Manager, and have seen a profile or permission set in Setup. Basic Apex and SOQL syntax helps for the last section.
What object permissions are
Object permissions decide what a user can do with an object as a whole. There are six:
| Permission | Lets the user |
|---|---|
| Read | View records of the object |
| Create | Create new records |
| Edit | Update existing records |
| Delete | Delete records they can access |
| View All | View every record, ignoring sharing |
| Modify All | Edit and delete every record, ignoring sharing |
The first four are often called CRUD (create, read, update, delete). View All and Modify All override record sharing for that object, so grant them sparingly.
Why they come first
Salesforce checks access in layers. A user must pass the object layer before field-level security (FLS) can matter. If a user has no Read permission on Account, they cannot see the object. Their field settings on Account are irrelevant, even if every field is marked readable.
Object permissions also set an upper limit on field edits. A user with Read but not Edit on an object cannot edit any of its fields. This holds even when FLS marks a field Editable. Edit on a field only helps if the object also allows Edit.
Permissions add up
A user's access is the union of their profile and all assigned permission sets. A permission set can grant access but cannot take it away. So if the profile grants Delete on Account, you cannot remove it by assigning a permission set. You have to remove it from the profile. This is why many teams give profiles minimal access and add permissions through permission sets.
A common error in Apex
Apex normally runs in system mode and skips these checks. When you opt in to user mode, the object check runs first. Here the user has no Read access to Account:
try {
List<Account> accounts = [
SELECT Id, Name
FROM Account
WITH USER_MODE
];
} catch (QueryException e) {
System.debug('Blocked: ' + e.getMessage());
}The query throws a QueryException before any field is considered. Later chapters cover enforcement in detail. For now, remember that user mode checks the object first and then each field.
Practical checks
When someone reports that a field is missing, work from the top down:
- Confirm the user has Read on the object in their profile or permission sets.
- Confirm sharing gives them the record.
- Only then check the field's Read and Edit settings.
Starting at the field is a common mistake. It wastes time when the real cause is a missing object permission.
Exercise
A user has Edit on the Opportunity object, but the Discount_c field is Read-only for them in FLS. Can they change Discountc? Now suppose the user has only Read on Opportunity and Discount_c is Editable in FLS. Can they change it?
Show answer
In the first case, no. FLS limits the field to Read, so object Edit does not help. In the second case, no. Without Edit on the object, no field on it can be edited. A user needs both object Edit and field Edit.