I want to know version number of managed packages installed.

I have identified two ways to get that information as shown below but they are not supported in API Version 29.0.

Approach 1: Query Publisher object

Approach 2: Using System.requestVersion()

So, I want to know is there any way to fetch package version details from Apex class which is created with API Version 29.0

  • 1
    Why does the class need to remain at v29.0? It seems the easy solution is to upgrade the API version.
    – sfdcfox
    May 13, 2019 at 15:33
  • Actually, my apex class is very big and was created by someone else. So, I am not sure what it impacts on upgrading API Version. So, I want to avoid upgrade if possible.
    – rakesh
    May 14, 2019 at 6:34
  • One more thought came in my mind, if it is possible - Create new static class with latest API Version and then create one static method which gives me package version. And then, call this method from my existing class. Will it work?
    – rakesh
    May 14, 2019 at 6:37
  • "Maybe." I've discussed why mixing API versions is a bad idea, and generally discourage it. It may work, or it may introduce new bugs. Also, the Publisher object, for example, still won't be available in the other class, so you'd need a custom wrapper. If you have proper unit tests, changing API version should be safe, and if you don't have proper tests, consider writing them now.
    – sfdcfox
    May 14, 2019 at 12:02

1 Answer 1


Well, instead of querying Publisher object or using System.requestVersion() it is possible to create some custom logic to store the value of Version in PostInstallContext into some protected custom setting.

Then, when needed, the current package version can be read from that custom setting.

Another option would be to maintain the package version as a constant in some apex class and update that line with CI on every package version creation step.

Also, if you have access to Session Id and Tooling API, it is possible to perform Tooling Api query

SELECT Id, SubscriberPackageId, SubscriberPackage.NamespacePrefix,
    SubscriberPackage.Name, SubscriberPackageVersion.Id,
    SubscriberPackageVersion.Name, SubscriberPackageVersion.MajorVersion,
FROM InstalledSubscriberPackage 
ORDER BY SubscriberPackageId

You must log in to answer this question.

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