Scenario: your company purchased X licenses for a package software installed in Salesforce, what is the easy way to extract users has been granted with that package software?
Solution: open the Package Details then click the "Manage Licenses" button. However, this is not easy when you have thousands of users.
Alternative solution: use SOQL, so we can extract the data easily.
1. Query the Package Id
You need to know the Namespace Prefix of the package to get the Package Id. You can get the Namespace Prefix from Package Details, including allowed licenses and used licenses.
SELECT Id, NamespacePrefix, AllowedLicenses, UsedLicenses, CreatedDate, ExpirationDate, Status FROM PackageLicense ORDER BY NamespacePrefix
2. Query User Package License object
SELECT Id, PackageLicenseId, CreatedById, CreatedDate, UserId FROM UserPackageLicense
By query UserPackageLicense object and filter with PackageLicenseId, you can get :
- UserId: user assigned with the license
- CreatedById: who grants the license
- CreatedByDate: when is the license granted
But unfortunately, you can't use relationship query for UserId to get the name and profile and so on, so you need to query to User object again, subscribe for this KI.
No comments:
Post a Comment