Newer Version Available

This content describes an older version of this product. View Latest

Setting Package Versions for Apex Classes and Triggers

As a managed package subscriber, you can specify which package version that your managed Apex classes and triggers use.

In Summer ’25 and later, package subscribers can use version settings to specify the version of a migrated second-generation managed package (2GP) that an Apex class or trigger depends on. This functionality is already available to first-generation managed packages (1GP), but isn’t yet supported in 2GP packages that weren’t converted from a 1GP package. See Apex Version Settings in Migrated Second-Generation Managed Packages (2GP).

Note

To configure the package version settings for a class or trigger:

  1. From Setup, enter Apex Classes or Apex Triggers in the Quick Find box, and then select Apex Classes or Apex Triggers.
  2. From the list, click Edit for the Apex class or trigger that you want to configure.
  3. Click the Version Settings tab.
  4. From the Version dropdown for the managed package, select the desired version referenced by the class or trigger.
    The class or trigger continues to use this version even if you install later versions of the managed package, unless you manually update the version setting.
  5. Click Save.

When working with package version settings, keep these considerations in mind.

  • By default, an Apex class or trigger that references a managed package is associated with the version of the package installed when that class or trigger was last saved or deployed.
  • If a class or trigger references a managed package, you can’t remove the package’s version settings for that class or trigger. To find where the class or trigger references a managed package, on the class or trigger’s Detail page, click Show Dependencies.

You can also set the package version for an Apex class or trigger through metadata deployments or with API requests. See Set Package Versions for Apex Classes and Triggers.

Tip