Loading
Enhance Salesforce with Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Manage Version Settings for Apex

          Manage Version Settings for Apex

          To aid backwards-compatibility, Apex classes and triggers are stored with version settings for the Salesforce API and any referenced managed packages.

          Required Editions

          Available in: Salesforce Classic (not available in all orgs) and Lightning Experience

          Available in: Performance, Unlimited, Developer, Enterprise, and Database.com Editions

          Managed Packages are not available in Database.com.

          User Permissions Needed
          To define, edit, delete, set security, and set version settings for Apex classes: Author Apex
          To run Apex tests: View Setup and Configuration

          If the Apex class references components, such as a custom object, in installed managed packages, the version settings for each managed package referenced by the class is saved too. This ensures that as Apex, the API, and the components in managed packages evolve in subsequent released versions, a class or trigger is still bound to versions with specific, known behavior.

          A package version is a number that identifies the set of components uploaded in a package. The version number has the format majorNumber.minorNumber.patchNumber (for example, 2.1.3). The major and minor numbers increase to a chosen value during every major release. The patchNumber is generated and updated only for a patch release. Publishers can use package versions to evolve the components in their managed packages gracefully by releasing subsequent package versions without breaking existing customer integrations using the package.

          1. Edit either a class or trigger, and click Version Settings.
          2. Select the Version of the Salesforce API. This is also the version of Apex associated with the class or trigger.
          3. Click Save.

          Configure the Package Version Settings for a Class or Trigger

          Note
          Note 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).
          • If you save an Apex class or trigger that references a managed package without specifying a version of the managed package, the Apex class or trigger is associated with the latest installed version of the managed package by default.
          • You cannot Remove a class or trigger's version setting for a managed package if the package is referenced in the class or trigger. Use Show Dependencies to find where a managed package is referenced by a class or a trigger.
          1. Edit either a class or trigger, and click Version Settings
          2. Select a Version for each managed package referenced by the class or trigger. This version of the managed package will continue to be used by the class or trigger if later versions of the managed package are installed, unless you manually update the version setting. To add an installed managed package to the settings list, select a package from the list of available packages. The list is only displayed if you have an installed managed package that is not already associated with the class or trigger.
          3. Click Save.
          Tip
          Tip 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 in the Apex Developer Guide.
           
          Loading
          Salesforce Help | Article