Sub topic 10
Managing licenses and upgrades
This chapter covers two things that continue after an install: who may use a package under its license, and how new versions reach your org. Both can break a working app. An expired license can lock users out. An unreviewed upgrade can change what the app does with your data.
This chapter assumes you can do the following:
- Navigate Setup and assign permission sets.
- Tell a sandbox from production.
- Read the package details from earlier chapters, including the 04t package version ID and the managed or unmanaged distinction.
Two separate controls: license and permissions
A package license and a permission set solve different problems.
- The package license says whether a user is entitled to use the app. It is a commercial and technical gate set by the publisher.
- Permission sets and profiles say what a licensed user may do with objects, fields, and features. Your org controls these.
A user needs both. If you assign a permission set but the user has no package license, the user still can't use the app's components. If a user has a license but no permissions, the user sees little or nothing. When someone reports "I can't see the app," check both.
How package licensing works
Only some packages use licensing. A managed package can be license-managed by its publisher. An unmanaged package has no licensing at all. Once installed, its components are ordinary components in your org.
For a license-managed package, the publisher chooses one of two models:
- Site license. Every active user in the org can use the app. There is no seat count to manage.
- Per-user license. The publisher sells a number of seats. You assign each seat to a named user.
You find license information in Setup under Installed Packages. If a package has a Manage Licenses link, it is license-managed. The page shows the license status, the number of allowed licenses, the number used, and the expiration date. For per-user licenses, you add or remove users there.
License statuses
| Status | Meaning | What to do |
|---|---|---|
| Trial | Time-limited evaluation. Has an expiration date. | Decide before it expires. Don't build a production process on it. |
| Active | Paid license in force. | Monitor seat usage and the renewal date. |
| Free | Publisher grants use at no charge. | Still review upgrades and permissions. |
| Suspended | Publisher disabled the license, often for non-payment. | Contact the publisher. Users lose access. |
| Expired | Trial or term ended. | Renew, or plan an uninstall. |
| Uninstalled | The package was removed from the org. | No action. The license record remains for history. |
What happens when a license lapses
Licensed users lose access to the app's components, but your data stays. Records of custom objects the app created usually remain, though users can't work with them in the app. This matters for your rollback plan. If a business process depends on the app, an expired license is an outage even though nothing was uninstalled.
Assigning seats
For per-user licenses, you assign a seat to each user who needs the app. Do this in the same step as permission set assignment, so access is complete and deliberate. Remove the seat when a user leaves or changes role, because an unused seat is a cost, and an assigned seat on a departed user's account is a small access risk.
You can also read license data with SOQL. This query shows the license position for each license-managed package in the sandbox:
sf data query --target-org my-sandbox --query "SELECT NamespacePrefix, Status, AllowedLicenses, UsedLicenses, ExpirationDate FROM PackageLicense"An AllowedLicenses value of -1 indicates an unlimited site license. Compare UsedLicenses against AllowedLicenses regularly. To see which users hold seats, query UserPackageLicense:
sf data query --target-org my-sandbox --query "SELECT UserId, PackageLicense.NamespacePrefix FROM UserPackageLicense"Sandboxes and licenses
A sandbox refresh copies installed packages from production. License handling in sandboxes can differ from production. Some publishers give sandboxes free or trial treatment, and others require a separate arrangement. Check the publisher's documentation, and don't assume a sandbox test proves your seat count. Test access and behavior in the sandbox. Confirm commercial terms with the publisher.
How upgrades work
A package version is identified by a version number, such as 2.4.1 (major, minor, patch), and by its 04t ID. Each released version has a different 04t ID. The ID you used to install version 2.3 is not the ID for 2.4.
Pull upgrades
You choose when to upgrade. For a managed package, you install the newer version over the existing one. Salesforce replaces the package's components with the new versions and keeps your data. Settings you changed on the package's components may be preserved or overwritten, depending on whether the component is editable after install. Read the release notes for specifics.
Rules to remember:
- You can't downgrade. There is no "install an older version over a newer one." To return to an older version, you uninstall the package, which deletes its data, and install the old version. Treat every upgrade as one-way.
- Beta versions of managed packages can't be installed in production. They can only go in sandboxes or test orgs. Don't plan a production rollout around a beta.
- Unmanaged packages have no upgrade path. Installing a newer unmanaged package copies components into the org again. Components with the same names may be overwritten, and any customizations you made to them are lost. Compare the contents before you do this.
Push upgrades
A managed package publisher can also push an upgrade to subscriber orgs. You don't start these. They usually happen during a maintenance window, and publishers are expected to announce them. Push upgrades are meant for fixes and compatible changes, and they apply to the whole org at once.
You can't rehearse a push upgrade in the same way as a pull upgrade, but you can prepare:
- Subscribe to the publisher's release announcements and the Salesforce release schedule.
- Keep a sandbox that mirrors production's package versions, so you can see the new version there first. Publishers often push to sandboxes ahead of production, but confirm this with them.
- Keep a regression checklist for the business processes the app supports. Run it after any version change.
Upgrade workflow
Upgrading from the command line
The same sf package install command used for a first install also performs a pull upgrade when you give it a newer version ID. Replace the placeholder with the 04t ID of the new version from the publisher's listing or release notes. Always target the sandbox first.
sf package install --package 04tXXXXXXXXXXXXXXX --target-org my-sandbox --security-type AdminsOnly --wait 10Then list what is installed to confirm the version number changed:
sf package installed list --target-org my-sandboxUse --security-type AdminsOnly again. For an upgrade, this limits who gets access to any new components the version adds, so a new object or tab doesn't become visible to everyone by default. You then grant the new access deliberately.
What to check in an upgrade
An upgrade can change the app's risk profile. Before you move a version to production, compare it with what you approved at install time.
- New permissions or permission set changes. The new version may add fields or objects to the app's permission sets. A user who already holds the permission set can then gain access to them without any action by you.
- New external connections. Look for new remote site settings, named credentials, or connected apps. Each is a new place where data may leave your org.
- New components. New objects, Apex classes, flows, or page layouts can change the experience for users.
- Deprecated or removed components. Some components can be deleted by an upgrade. Find any of your own reports, flows, or code that referenced them.
- API version or dependency changes. An upgrade can add a dependency on another package or a feature your org doesn't have.
Common errors
- Assigning the permission set but not the license. The user still can't reach the app's components. Check both.
- Treating a trial as permanent. The app stops working on the expiration date, and no one is notified who wasn't watching. Put the date in a calendar and track it in your governance records.
- Over-buying or under-buying seats. Compare
UsedLicensesandAllowedLicensesbefore each renewal. - Skipping the sandbox for a "small" version. A minor version can add a new permission or connection. The sandbox is where you see that first.
- Assuming you can roll back. You can't install an older version over a newer one. Your rollback plan is the one from the previous chapters: an uninstall plus a data export, or a sandbox you can restore from.
- Forgetting the sandbox is a copy. After a refresh, the sandbox has the production versions at the time of the refresh. A sandbox that hasn't been refreshed may be on a different version than production, so your test may not match what production will get.
- Ignoring publisher communications. Push upgrade notices often go to a single admin's email. Use a shared mailbox or distribution list so notices aren't lost when that person leaves.
A routine you can reuse
Run this each time a version is announced and each quarter for every installed package:
- Record the installed version and license status with the two commands above.
- Read the release notes and note any changes to permissions or external connections.
- Upgrade in a sandbox, then run your regression checklist.
- Re-review the app's permission sets and who holds them.
- Check the license expiration date and seat usage.
- Upgrade in production in a quiet window, then repeat the post-install verification steps.
Exercise
Your org has a per-user license for a managed package, and a new version has just been released. Name three checks you make before upgrading production, and say why you can't simply "roll back" if the upgrade goes wrong.
Show answer
Any three of: read the release notes for new permissions or permission set changes, look for new external connections such as remote site settings or connected apps, upgrade in a sandbox and run a regression checklist, and check that licenses haven't expired and seats are available. You can't roll back because Salesforce doesn't let you install an older package version over a newer one. Returning to an older version means uninstalling the package, which deletes its data, and installing the old version. This is why you export data and test in a sandbox first.
Exercise
A user was given the app's permission set but still can't open the app. The package is license-managed with per-user licenses. What do you check, and which query shows the license position?
Show answer
Check whether the user holds a package license seat, since a permission set alone doesn't give one. In Setup, open Installed Packages, then Manage Licenses, and add the user. To check from the command line, query PackageLicense for Status, AllowedLicenses, UsedLicenses, and ExpirationDate, and query UserPackageLicense to see which users hold seats. Also confirm the license isn't expired or suspended.