I'm trying to properly build a relative URL from within a managed package context, so that a simple link can be provided to the user to bring them to the assign licenses page specifically for that managed package.
When you have an installed managed package that requires assigning licenses, you can go to the follow relative URL which shows the assign licenses page:
/lightning/setup/Package/0332E000000JJeF/UserLicenses/0501U000000TZHP/view
The first Id is the Package
object Id, while the second Id is the PackageLicense
object Id.
PackageLicense
is queryable via SOQL and you can get rich data like AllowedLicenses
and UsedLicenses
on the installed package (can grab the right one via NamespacePrefix
).
Unfortunately the PackageLicense doesn't specify the actual Package
Id itself, and Package
object itself isn't queryable.
Is there any way to get that first Id using SOQL?
Updates
First Attempt
Tried querying
Publisher
as suggested here, but it doesn't show any Package IdThe Tooling API actually pulls up the right package Id. By following this post's suggestion, I was able to pull up the right Package Id via the
InstalledSubscriberPackage.SubscriberPackageId
field
Second Attempt
MetadataPackage only shows packages developed within the org, not installed packages.
PackageSubscriber is only available on the developer org in which you developed the managed package