Sub topic 14
Tracking subscribers and licenses with the License Management App
This chapter assumes you can already build and promote a managed package version and that you know basic Apex. It also assumes you know what a subscriber org is. A subscriber org is a Salesforce org that has installed your package.
What the License Management App does
The License Management App (LMA) is a free managed app from Salesforce. You install it in one org that you choose, called the License Management Org (LMO). Many partners use their Partner Business Org for this. The LMA records who installed your package and lets you control whether they can keep using it.
You can only license a package after you have connected it to the LMO. Salesforce handles this connection through the partner publishing tools, and the steps change over time, so follow the current partner documentation.
What happens when someone installs
For each install or upgrade, the LMA creates records in the LMO:
| Record | What it tells you |
|---|---|
| Package and Package Version | Which of your packages and versions exist |
| Lead | The person who installed, with their company and org details |
| License | The subscriber org's right to use the package |
A License has a status, a seat count, and an expiration date. The status can be Trial, Active, Suspended, or Uninstalled. The seat count can be a number or unlimited. The expiration date can be left empty if the license never expires.
Setting default license terms
Each package has default license settings. These set whether new installs start as a trial, how long the trial lasts, and how many seats it includes. A common setup is a 30-day trial with a fixed seat count. After a customer buys, you change that customer's license to Active and remove the expiration date.
You change a license by editing its record in the LMO. The change reaches the subscriber org without a reinstall. A suspended or expired license blocks users from the package, but their data stays in the org.
Assigning licenses in the subscriber org
Installing the package does not give anyone access. A subscriber admin opens Manage Licenses in Setup and assigns the available seats to users. Users without a seat cannot use the package's features.
Checking the license in Apex
Your code can check whether the current user holds a seat. Use UserInfo.isCurrentUserLicensed with your namespace prefix:
public with sharing class LicenseGuard {
public static Boolean userHasSeat() {
return UserInfo.isCurrentUserLicensed('acme');
}
public static void requireSeat() {
if (!userHasSeat()) {
throw new AuraHandledException(
'You need an Acme license to use this feature.');
}
}
}Packages that are licensed through the LMA rarely need this check for standard UI access. Salesforce already enforces the license on package components. The check is useful for custom behavior, such as limiting an API-style feature to seated users.
Common errors
- Installs missing from the LMO. The package was never connected to the LMO. Check the connection before you share the install link.
- Users cannot see the app after install. The admin has not assigned seats in Manage Licenses.
- Wrong namespace in the Apex check. The method needs the namespace prefix, not the package name.
Exercise
A customer finishes a 30-day trial and buys your app. Which record do you change, in which org, and what do you change on it?
Show answer
Edit the customer's License record in the LMO. Set the status to Active, set the seat count to the purchased number, and clear the expiration date. The change syncs to the subscriber org, and the admin then assigns seats in Manage Licenses.