Sub topic 14
Deactivating users and releasing licences
This chapter assumes you can open Setup, know what a profile and a permission set are, and have read the earlier chapters on licence capacity and user creation. The optional code uses basic SOQL.
Why users are deactivated, not deleted
Salesforce does not let you delete a user. A user record is referenced by the records they own, the history of changes they made, and fields such as CreatedBy. Deleting the user would break those references, so the platform only allows you to deactivate the user.
Deactivation has two effects:
- The user can no longer log in.
- The user stops consuming a licence, so the count in
UsedLicensesgoes down by one.
The user record, the username and the audit trail stay in the org. Because the username stays, you cannot reuse it for a new user. Plan for this when you choose usernames.
Deactivate a user in Setup
- In Setup, enter Users in Quick Find and select Users.
- Click Edit next to the user.
- Clear the Active checkbox.
- Click Save, then confirm the warning.
The licence is released as soon as the save succeeds. You can confirm it by running the licence query from the capacity chapter again.
SELECT Name, TotalLicenses, UsedLicenses
FROM UserLicense
ORDER BY NameTo bring someone back, edit the user and select Active again. This needs a free licence of the right type. If none is free, the save fails.
Freeze a user instead
Sometimes you need to block a login right away but are not ready to deactivate. This happens when the user owns records used in assignment rules, or when you are still deciding what to do with their work.
Freezing is a separate action. On the user's detail page, click Freeze. Use Unfreeze to reverse it.
| Action | Can log in | Releases a licence | Typical use |
|---|---|---|---|
| Freeze | No | No | Immediate, temporary block while you investigate |
| Deactivate | No | Yes | The person has left or no longer needs access |
A frozen user still counts against your licence total. If your aim is to free capacity, you must deactivate.
What to do before deactivating
Deactivation does not move the user's records. Work through this checklist first:
- Transfer ownership of records, or reassign them in bulk, so that no important data stays with an inactive owner.
- Replace the user in approval processes, assignment rules, queues and any scheduled jobs they run.
- Remove the user from public groups and queues if the membership matters.
- Review any integrations that log in with this username. Deactivating an integration user stops the integration.
The process at a glance
Common mistakes
- Expecting a freed licence after a freeze. Frozen users still use a licence.
- Reactivating with no capacity. The save fails until another user is deactivated or you buy more licences.
- Forgetting integration users. A deactivated API user breaks scheduled syncs without any warning in the UI.
- Trying to reuse a username. The old, inactive record still owns it. Give the new user a different username.
Exercise
A contractor leaves today. You freeze their account, and later your licence query shows the same UsedLicenses value as before. Why, and what should you do if you want the licence back?
Show answer
Freezing blocks login but does not release the licence, so UsedLicenses did not change. Reassign the contractor's records and dependencies, then deactivate the user by clearing Active. After the save, the licence count drops by one.