Sub topic 2
Profiles and permission sets: the containers for access
This chapter assumes you know what objects, fields, records, and users are, and that you can find Setup and the Object Manager. You don't need Apex yet.
Salesforce doesn't attach access rules to individual users one by one. It stores them in containers, and each user gets access from the containers assigned to them. Field-level security (FLS) is one of the settings stored in those containers.
The two containers
A profile is a container of settings that every user must have. Each user has exactly one profile. It holds object permissions, field permissions, app and tab visibility, and system settings such as login hours.
A permission set is an optional container that adds access on top of the profile. A user can have many permission sets. A permission set can only grant access. It cannot take away access that the profile already gives.
| Feature | Profile | Permission set |
|---|---|---|
| Per user | Exactly one | Zero or more |
| Can grant access | Yes | Yes |
| Can remove access | Only by leaving it unset | No |
| Typical use | Baseline for a job type | Extra access for a task or team |
How access combines
Salesforce takes the union of all containers assigned to a user. If the profile gives Read on Account.AnnualRevenue and a permission set gives Edit, the user can edit it. If one container grants a permission, no other container can cancel it.
In this example the user can edit AnnualRevenue and read Internal_Notes__c.
Choosing the right container
Use the profile for what everyone in a role needs. Use permission sets for anything that only some of those users need. Salesforce recommends keeping profiles minimal and granting extra access through permission sets. This avoids creating a new profile for each small difference.
For example, suppose a team of sales reps shares one profile, but only two of them may see Internal_Notes__c. Create a permission set named "Account Notes Access" with Read on that field. Assign it to those two users. The other reps are unaffected.
Common errors
- Granting too much in the profile. Access placed in a profile reaches every user with that profile. Put it in a permission set when only some users need it.
- Trying to remove access with a permission set. A permission set can't revoke. If a user has unwanted access, find which container grants it and change that container.
- Missing the object permission. Field access is only useful if the user can also reach the object. The next chapter covers this.
- Debugging the wrong user. Check the user's profile and every assigned permission set before you decide where an access came from.
Exercise
A user's profile gives Read but not Edit on Account.AnnualRevenue. You assign a permission set that gives Edit on that field. Then you assign a second permission set that gives no access to that field. Can the user edit AnnualRevenue? Explain.
Show answer
Yes. Access is the union of the profile and all permission sets. The first permission set grants Edit, and the second set doesn't grant anything that could cancel it. A permission set that leaves a field unset doesn't remove access given elsewhere.
Exercise
Only three of fifty users who share a profile need to edit InternalNotes_c. Should you change the profile or use another container? Why?
Show answer
Use a permission set. Changing the profile would give all fifty users the access. A permission set with Edit on the field, assigned to the three users, limits the access to them.