Our users will be using many different managed package versions. As users can be using versions which don't have the latest features, I need to know which package is being used by a user who will log in to Salesforce from an external application and invoke Apex web services.

I've been looking for a way to access this number from within Apex but I can't find anything.

This could also be accessed from the external application, and I found the following documentation which mentions the PackageVersion and PackageVersionHeader API classes. However, I don't know if this respects the logged-in user or simply lists all packages being used in SFDC, and I don't have access to the external application to check.

Does anyone have any idea how I can do this?

3 Answers 3


I found the Apex call System.requestVersion() which seems to solve my problem. I found this link, which gives examples of logic based on version number, to be very helpful. The Version class is also worth a look.


This isn't necessarily the answer you're looking for, but one way to do this could be to just have a static string member variable in a class which becomes part of your package. Each time you update the package you could update the value of the string and then read that from wherever else you need to.

// the class
class CVersionTracker
  public static string version = "1.0";

// inside a method of some other class
if (CVersionTracker.version == "1.0")
    // take some action
    // take the new improved action!

Depending on your requirements for the version number of course, an integer or double might be the simpler option (though it maybe not reflect the actual version) as it would let you leverage the > and < operators.

If the remote application needs to take different actions depending on the version then you could just add a new webservice method to return this version number to the client.


There are a lot of calls you can make through the SOAP/WS external API that you can't make in APEX.

I don't believe there is a managed package version detection in the APEX api.

You must log in to answer this question.

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