Print this page

How to read package version number (package installed in the Org) from a apex trigger.

Knowledge Article Number 000181377
Description How can we check the version number of a package using a Trigger?
Resolution The System.requestVersion method instantiates the System.Version class to determine the package versions via an Apex trigger. The package version setting of the calling code can be determined within the package code by calling the System.requestVersion method.

To compare the current package version:

trigger oppValidation on Opportunity (before insert, before update) {

    for (Opportunity o :{
        if (System.requestVersion().compareTo(new Version(1,0)) > 0) {



promote demote