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:


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?


First Attempt

  • Tried querying Publisher as suggested here, but it doesn't show any Package Id

  • The 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

2 Answers 2


For 1GP packages, I think that first Id never changes - looks to me as if it is actually the Id of the package in the packaging org (i.e. the Id in the URL when you got to create packages in the packaging org). I looked in a few customer/test orgs I have access to, and the Id is that same Id in each org.

So I am thinking you can just add the Id to a protected custom metadata setting, add to the package and query it when you need it. Combined with the PackageLicense info, you should have what you need.

  • 2
    The 033 id does identify a specific package across versions.
    – David Reed
    Commented Feb 11, 2020 at 1:02
  • So actually, you could probably just hardcode it into the link? Commented Feb 11, 2020 at 1:19
  • 1
    Terrible as it is to even suggest hard-coding a Salesforce Id... yeah, that sounds just fine!
    – David Reed
    Commented Feb 11, 2020 at 1:38
  • 1
    Ah, fair point - it would cause the Source Scanner to have a minor meltdown, so yes, my initial suggestion of CMD might be a better option. Commented Feb 11, 2020 at 1:40
  • 1
    @DavidReed Well, I'm embarrassed yet happy to report that hardcoding the 1GP package Id indeed worked - it seems the managed package's Id is set in stone as BritishBoyinDC mentioned, and then I'm able to build out the licenses Id dynamically per org Commented Feb 13, 2020 at 18:13

I'm not sure what sObject you can query (this has always been a bit troublesome), but there's an easy alternative: SFDX.

$ sfdx force:package:installed:list -u user-alias

ID                  Package ID          Package Name  Namespace        Package Version ID  Version Name     Version
──────────────────  ──────────────────  ────────────  ───────────────  ──────────────────  ───────────────  ────────
0A350000000R6wECAS  033A0000000TeSFIA0  Field Trip    Field_Trip       04tA0000000FTkoIAG  Ichiban

This gives you the 033 Id you need, as well as the 04t version ID, if you need that for other purposes.

  • Nice, but at the end of the day, I'm just trying to get that relative URL working from within a managed package context, and I think it's overkill to get a whole REST Tooling API callout working within the managed package just to get that Id. Just updated my original question so that my objective is clearer and avoiding the XY Problem Commented Feb 10, 2020 at 22:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .