Sub topic 3
Checking how many licences you have left
Before you create a user, confirm the org has a free licence of the right type. This chapter assumes you know what a user licence and a profile are, can open Setup, and have read basic SOQL. You also need the View Setup and Configuration permission or higher.
Why capacity matters
Every active user consumes one user licence. Some access also needs a permission set licence. If the pool is empty, creation fails with an error such as "License limit exceeded". Checking first avoids that failure and tells you whether you must deactivate a user or contact your Salesforce account executive.
Two numbers matter for each licence:
- Total: how many licences the org has purchased or been granted.
- Used: how many are assigned to active users.
Remaining capacity is Total minus Used.
Checking in Setup
- Click the gear icon, then Setup.
- In Quick Find, enter Company Information and open it.
- Scroll to User Licenses. Each row shows the licence name, status, total licences, used licences, and remaining licences.
- Scroll to Permission Set Licenses for the same figures on feature-level licences.
Only active users count as used. A deactivated user releases the licence for reuse.
Checking with SOQL
Setup works for a quick look. A query is better when you want to sort, filter, or repeat the check. Run these in the Developer Console Query Editor or in Workbench.
This query lists each user licence type with its total and used counts:
SELECT Name, TotalLicenses, UsedLicenses
FROM UserLicense
ORDER BY NameThis query does the same for permission set licences. Run it before you assign a permission set that requires one:
SELECT MasterLabel, TotalLicenses, UsedLicenses
FROM PermissionSetLicense
ORDER BY MasterLabelSOQL does not compute the remaining count for you, so subtract in your head or in a report. The UserLicense object also has a Status field, so filter on it if you only want active licence types.
Reading the results
Suppose the first query returns these rows:
| Name | TotalLicenses | UsedLicenses |
|---|---|---|
| Salesforce | 25 | 25 |
| Salesforce Platform | 10 | 6 |
| Identity | 100 | 12 |
You cannot create another user on the Salesforce licence, because 25 of 25 are used. Salesforce Platform has 4 left, so a user with a profile on that licence can be created.
Common mistakes
- Checking the wrong licence type. A profile is tied to one user licence. Capacity on a different licence does not help.
- Forgetting permission set licences. The user licence can be free while the feature licence is exhausted. The failure then appears at assignment time, not creation time.
- Assuming a frozen user frees a licence. Freezing blocks login but the user stays active and still counts as used. Only deactivation releases the licence.
- Expecting unlimited licences in a sandbox. Sandboxes copy licence counts according to the sandbox type, so check the sandbox itself.
Exercise
Your query returns Salesforce with TotalLicenses 40 and UsedLicenses 38. You must create three users who all need a profile on this licence. Can you do it, and what are your options?
Show answer
No. Only 2 licences remain (40 minus 38), so the third user would fail. Options: deactivate an unused user to release a licence, ask Salesforce for additional licences, or use a profile on a different licence type that has capacity, if it meets the users' needs. Freezing a user does not help, because frozen users still count as used.