license agent failed: Salesforce license type mapping changed, counts wrong
Fixes license agents with wrong counts after Salesforce changed its license type mapping. Use when Salesforce counts shift with no tenant change. Not for permission-set limits.
TL;DR
Refresh the license-type mapping from the live UserLicense object instead of a hardcoded table. Salesforce renames and reclassifies license types, and stale mappings miscount.
Error
(counts dropped 15 percent overnight; no tenant change; mapping table stale; no error text)Steps
- Confirm the mapping drift: query the UserLicense object and compare its names and statuses against the agent's hardcoded mapping. Expected: the drift identified.
- Replace the hardcoded mapping with a runtime lookup against UserLicense (and PermissionSetLicense where relevant). Expected: the mapping always current.
- Re-run the counts. Expected: the numbers match the Salesforce UI.
- Add a periodic re-check so future Salesforce changes surface as mapping updates, not silent miscounts. Expected: drift detection in place.
When to use
- Salesforce license counts change with no tenant change
- The agent uses a hardcoded license-type table
- Salesforce announced license changes
When not to use
- Counts are wrong right after a real tenant change (expected)
- The issue is a permission-set license limit (a different problem)
- The API errors (an API problem)
Tool compatibility
Salesforce UserLicense and PermissionSetLicense objects.
Variant phrasings
mapping changed for one license family only
Refresh the whole mapping anyway; partial updates rot again.
agent caches the mapping for months
Shorten the cache or refresh on every run; the lookup is cheap.
Why it happens
Salesforce evolves its license catalog, but hardcoded mappings freeze a moment in time. The count silently follows the stale mapping until someone notices the drift.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_FtA4RJHMwQuDiZafgCCpUg