Sub topic 2
Profiles: one per user, the baseline of access
This chapter assumes you can navigate Setup, know the difference between standard and custom objects and fields, and know that every person who logs in has a User record. You should also know the basic idea of record sharing (org-wide defaults and roles). Profiles do not control sharing, a point this chapter returns to below.
What a profile is
A profile is a collection of settings and permissions that defines what a user can do and see. Every user has exactly one profile, and it is a required field on the User record. You cannot create a user without one, and you cannot assign two.
Because of this, the profile is the baseline of a user's access. Permission sets and permission set groups, covered in later chapters, add to that baseline. They do not replace it.
A profile holds two kinds of settings:
- Permissions: object permissions, field-level security, and system and user permissions. Permission sets can also grant these.
- Settings that live only on the profile: default app, record type defaults, page layout assignments, login hours, and login IP ranges. Permission sets cannot hold all of these, and a later chapter covers them in detail.
Where profiles fit in the access model
The result is a union. If the profile grants Read on Account, the user has Read on Account, whatever the permission sets say. A permission set can add access that the profile lacks. A permission set cannot take away access that the profile grants. Only a muting permission set inside a permission set group can remove permissions, and it removes them only from that group's contribution. It cannot reduce what the profile grants.
What a profile controls
A profile controls the following areas. Later chapters cover each one in depth.
| Area | What it decides | Also in permission sets? |
|---|---|---|
| Object permissions | Create, Read, Edit, Delete, View All, Modify All per object | Yes |
| Field-level security | Read and Edit per field | Yes |
| System and user permissions | Abilities such as exporting reports or managing users | Yes |
| App and tab visibility | Which apps and tabs the user sees | Yes (as assignments and visibility settings) |
| Apex class and Visualforce page access | Which code the user can run | Yes |
| Default app, record type defaults, page layout assignments | What the user sees by default | Partly. Page layout assignment is profile-only. |
| Login hours and login IP ranges | When and from where the user can log in | No |
The exact set of items a permission set can hold changes between Salesforce releases. Check the current documentation before you design around a specific setting.
Standard and custom profiles
Salesforce ships standard profiles such as Standard User, System Administrator, and Read Only. You can clone a standard profile into a custom profile.
Standard profiles have restrictions. In most cases you cannot edit their object permissions or field-level security. Some settings can be changed, but you cannot reshape them as you can with a custom profile. The System Administrator profile is an exception, but you should not edit it casually, because it is the profile your admins rely on to get back into the org.
For that reason, teams that use profiles heavily clone a standard profile and edit the clone. This works, but it leads to the problem described next.
The profile proliferation problem
Suppose the sales team needs access to a custom object called Quote Review, and a subset of reps also needs to approve discounts. With profiles alone, you need a separate profile for each combination of access:
- Sales Rep
- Sales Rep with Quote Review
- Sales Rep with Quote Review and discount approval
- Sales Manager
- Sales Manager with Quote Review
Each new combination adds a profile. When you later change something common to all sales users, you must edit every one of those profiles, and it is easy to miss one. The profiles drift apart, and nobody can say why two of them differ.
The modern answer is to keep the profile small and put job-function access in permission sets. The chapter on the Minimum Access profile covers that design. For now, treat the profile as the baseline, not as the place where all access lives.
Viewing and editing a profile
In Setup, enter Profiles in Quick Find and select a profile. Salesforce offers two views. Which one you see depends on your org settings. The enhanced profile user interface is the default view. It has a search box and organizes settings by page: Object Settings, App Settings, System Settings, and so on. The older original interface shows long lists with Edit buttons.
To clone a profile:
- Open the profile you want to copy.
- Click Clone.
- Enter a name for the new profile.
- Click Save, and then adjust its settings.
To change a user's profile, open the User record, click Edit, and select a different value in the Profile field. The new profile applies as soon as you save. The user keeps any permission sets they were assigned.
Reading profiles as metadata
Profiles can be retrieved and deployed with the Metadata API. A profile file is an XML file named <ProfileName>.profile-meta.xml. The following minimal example shows the shape of the file. It sets one object permission, one field permission, and one system permission on a custom profile.
<?xml version="1.0" encoding="UTF-8"?>
<Profile xmlns="http://soap.sforce.com/2006/04/metadata">
<custom>true</custom>
<userLicense>Salesforce</userLicense>
<objectPermissions>
<allowCreate>false</allowCreate>
<allowDelete>false</allowDelete>
<allowEdit>false</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>false</modifyAllRecords>
<object>Account</object>
<viewAllRecords>false</viewAllRecords>
</objectPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Account.AnnualRevenue</field>
<readable>true</readable>
</fieldPermissions>
<userPermissions>
<enabled>true</enabled>
<name>ApiEnabled</name>
</userPermissions>
</Profile>Two details matter. First, userLicense ties the profile to a user license, and that license limits which permissions the profile can grant. Second, the objectPermissions and fieldPermissions elements use the same structure as in a permission set, which makes it easier to move access from a profile into a permission set later.
Profile files retrieved from an org often contain only the items you named in the manifest. Deploying a partial profile changes only what the file contains. Be careful here, because the behavior depends on what you retrieved and deployed together.
Common errors
- Assuming a profile can be removed from a user. It cannot. You can only change it to a different profile. This is why a minimal profile is the usual starting point for a permission-set-led design.
- Editing a shared profile to fix one person's problem. The change reaches every user with that profile. If one user needs more, assign a permission set instead.
- Cloning a profile for every small variation. This produces the proliferation described above.
- Expecting object access to expose every record. Read on Account lets a user open the Account object, but record sharing decides which Accounts appear. A later chapter covers this distinction.
- Changing a profile in production and forgetting to capture it as metadata. The next deployment from source control then overwrites or loses the change.
- Editing the System Administrator profile to test a change. Test with a cloned or custom profile and a test user.
Checking which users hold a profile
You can count profile holders with SOQL in the Developer Console or any query tool.
SELECT Profile.Name, COUNT(Id) total
FROM User
WHERE IsActive = true
GROUP BY Profile.Name
ORDER BY COUNT(Id) DESCThis lists each profile with its number of active users. Profiles with a large count carry the largest risk when you edit them, and profiles with zero users are candidates for cleanup.
Key points
- Each user has exactly one profile, and it cannot be empty.
- The profile is the baseline. Permission sets and groups add to it.
- Some settings live only on the profile, such as login hours and login IP ranges.
- Standard profiles are restricted. Custom profiles are cloned from them.
- Too many profile variations make an org hard to maintain. Later chapters show how permission sets avoid that.
Exercise
A sales rep has the Sales Rep profile, which grants Read on the Quote Review object. An admin assigns the rep a permission set that does not mention Quote Review. Does the rep still have Read on Quote Review, and why?
Show answer
Yes. Effective access is the union of the profile and all assigned permission sets. A permission set that does not mention an object adds nothing and removes nothing, so the profile's Read permission remains.
Exercise
One user in a team of forty needs Delete on Case. All forty share the Support Agent profile. What is the better way to grant it, and why not edit the profile?
Show answer
Assign that user a permission set that grants Delete on Case. Editing the Support Agent profile would give Delete to all forty users. Cloning the profile for one person would add another profile to maintain.