Sub topic 14
Tracking Subscribers and Licenses with the License Management App
This chapter assumes you can build, promote, and install a managed 2GP version with the Salesforce CLI, and that you know what a Dev Hub, a namespace, and a subscriber org are. It covers the License Management App (LMA), the Salesforce app that records who installed your package and what they are allowed to do with it.
Why the LMA exists
After you publish a managed package, subscribers install it into their own orgs. You do not own those orgs, so you cannot see them. The LMA gives you a record of each install and lets you control access.
With the LMA you can:
- See which orgs have installed which version of your package.
- Give each subscriber a license with a seat count and an expiration date.
- Let a trial lapse, or turn off a customer who stopped paying.
- Find contact details for the installing org so your sales or support team can follow up.
The LMA only works for managed packages that go through AppExchange and security review. Unlocked packages and unmanaged metadata are not tracked this way.
How the LMA fits into the release process
The LMA is a Salesforce app that you install into one org of your choosing. That org is called the License Management Org (LMO). Use a stable production org, such as your business org. Do not use a scratch org or a sandbox, because a deleted or refreshed org loses the records.
When you register a package with the LMO, Salesforce sends a record to that org each time a subscriber installs, upgrades, or uninstalls the package.
Setting up the LMA
The usual path has four steps.
- Choose or create the production org that will be your LMO.
- Install the License Management App into that org. You request it through the Salesforce Partner Community, and Salesforce sends an install link.
- Associate your package with the LMO. For a 2GP package this happens in the Partner Business Org or the AppExchange publishing console, where you select the org that should receive license records.
- Create and release a package version, then install it in a test org to confirm a record arrives in the LMO.
Do the association before the first customer installs. Installs that happen before the package is linked to an LMO are not recorded, and you cannot easily recreate them later.
The records you work with
The LMA adds three main objects to the LMO.
| Object | What it represents | Typical use |
|---|---|---|
| Package | One managed package that you registered | Group all versions and licenses |
| Package Version | One released version of that package | See which version a subscriber runs |
| License | One subscriber org's right to use a package | Set seats, expiration, and status |
The License record is the one you edit most. Its key fields are:
- Status: Trial, Active, Suspended, or Uninstalled.
- Expiration Date: The day the license stops working. A license can also be set to never expire.
- Seats: The number of users who may use the package. A seat count can also be unlimited.
- Licensed Seats and Used Licenses: How many seats were granted and how many are assigned.
- Lead: A lead record created when the package is installed, which holds the installer's contact information.
Default license behavior
You set the default behavior for new installs on the Package record. Two choices matter most.
- Default license: Whether new subscribers get a license that lasts forever with unlimited seats, or a limited trial. A common setup is a trial with a fixed length and a small seat count.
- Status: Whether the license starts as Trial or Active.
If the package is not license-enforced, the subscriber can use it with no limits regardless of the License record. Enforcement depends on the licensing settings you chose when you published.
How licenses affect users
A license controls user access through license assignment in the subscriber org. The subscriber admin goes to Setup, opens Installed Packages, and chooses Manage Licenses to assign seats to users. A user without a seat cannot use the package's components that require a license.
When a license expires, the package stays installed. Data created by the package stays too. Users simply lose access until the license is renewed. This makes expiration a gentler tool than uninstalling.
Remember these points:
- Setting seats lower than the number of assigned users does not remove existing assignments immediately. The admin must reduce them.
- A license applies to the subscriber org, not to a single user.
- You edit licenses in the LMO. Subscribers cannot change their own seat counts.
Reading and editing licenses with SOQL
The LMA objects live in the sfLma namespace. You can query them in the LMO with SOQL to build reports. The query below lists active licenses for a package and when they expire.
SELECT sfLma__Subscriber_Org_ID__c,
sfLma__Status__c,
sfLma__Seats__c,
sfLma__Expiration_Date__c
FROM sfLma__License__c
WHERE sfLma__Status__c = 'Active'
ORDER BY sfLma__Expiration_Date__cYou can run it from the CLI against the LMO if you have authorized that org:
sf data query --target-org lmo --query "SELECT sfLma__Subscriber_Org_ID__c, sfLma__Status__c, sfLma__Seats__c FROM sfLma__License__c WHERE sfLma__Status__c = 'Active'"Field names depend on the installed LMA version, so check them in Object Manager in your LMO before relying on them in automation.
Licensing and upgrades
Licensing is independent of package versions. A subscriber who upgrades from version 1.0 to 1.1 keeps the same license record. Salesforce adds a new Package Version record and updates the license to point to it. You do not need to reissue licenses at upgrade time.
This is why you should plan your licensing model before the first release. Changing from per-org licensing to per-seat licensing later means editing every License record by hand or with a script.
Common errors
- No records appear after an install. The package was not linked to the LMO, or the install happened in a scratch org or sandbox. Test installs in sandboxes are normally not recorded.
- Users cannot access the app after install. The license has zero seats, or the admin has not assigned seats. Check the License record, then the Manage Licenses page in the subscriber org.
- Access stopped suddenly. The expiration date passed. Edit the License record to extend it.
- Lost history. The LMO was refreshed or deleted. Keep the LMO in production and export license data on a schedule.
Practical guidance
- Keep the LMO separate from your Dev Hub if your team differs, but a single org can hold both roles if you manage access carefully.
- Give sales and support staff access to the LMA objects, and give only a few people permission to edit License records.
- Set up a report or dashboard for licenses that expire in the next 30 days.
- Export the License records regularly as a backup.
Exercise
A customer installed your released package a week ago, and its trial license has now expired. The customer paid and wants to continue. In which org do you act, which record do you change, and what happens to the data the package already created?
Show answer
Act in the License Management Org. Open the customer's License record, change the status to Active, and set a new expiration date (or no expiration) and the seat count that was purchased. The package stays installed, and the data it created is still there, because expiration only removes user access. Once the license is updated, the subscriber admin can assign seats to users on the Manage Licenses page.
Exercise
Why should the License Management Org be a stable production org instead of a scratch org or sandbox?
Show answer
The LMO holds the only record of your subscribers, their license status, and their contact leads. Scratch orgs expire and sandboxes can be refreshed or deleted, which would destroy those records. A production org keeps the data safe.