Loading

How to Update Apex Classes, Triggers, and Visualforce Pages to API Version 45.0 or Higher

Veröffentlichungsdatum: Jul 21, 2026
Beschreibung

Every Apex class, trigger, and Visualforce page in Salesforce is compiled and executed against a specific API version. Components running on older API versions may behave differently from current platform expectations, miss new features, or encounter deprecated functionality. Salesforce recommends updating Apex code components to API version 45.0 or higher to maintain compatibility with current releases. This article explains how to update the API version using three methods: Salesforce Setup, the Developer Console, and VS Code with the Salesforce CLI.

Lösung

This article explains how to update the API version for Apex classes, Apex triggers, and Visualforce pages to version 45.0 or higher. Use the method that matches your development environment.

Method 1: Update API Version via Salesforce Setup

  1. Go to Setup by clicking the gear icon and selecting Setup.

  2. To update an Apex Class: In the Quick Find box, type Apex Classes and select it. Click Edit next to the class you want to update. Change the API Version field to 45.0 or higher and click Save.

  3. To update an Apex Trigger: In the Quick Find box, type Apex Triggers and select it. Click Edit next to the trigger. Change the API Version field to 45.0 or higher and click Save.

  4. To update a Visualforce Page: In the Quick Find box, type Visualforce Pages and select it. Click Edit next to the page. Change the API Version field to 45.0 or higher and click Save.

Method 2: Update API Version via the Developer Console

  1. Open the Developer Console from the gear icon menu.

  2. Go to File > Open and select the Apex class, trigger, or Visualforce page you want to update.

  3. In the file editor, click the Version Settings tab (at the bottom of the editor pane).

  4. Update the API Version to 45.0 or higher and click Save (Ctrl+S or Cmd+S).

Method 3: Update API Version via VS Code and Salesforce CLI

  1. Open your Salesforce DX project in VS Code.

  2. Locate the metadata file for the component you want to update. For an Apex class named `MyClass`, the file is `force-app/main/default/classes/MyClass.cls-meta.xml`.

  3. Open the `-meta.xml` file and update the `<apiVersion>` value to `45.0` or higher. For example:

    `<apiVersion>61.0</apiVersion>`

  4. Save the file and deploy the updated component to your org using the Salesforce CLI: `sf project deploy start -m ApexClass:MyClass`

Notes

Updating the API version of a component may change its runtime behavior if your code relies on features or defaults that differ between API versions. Test updated components in a sandbox before deploying to production. To check the current API version of all Apex classes in your org at once, query the `ApexClass` object in the Developer Console or Tooling API: `SELECT Name, ApiVersion FROM ApexClass ORDER BY ApiVersion ASC`.

Nummer des Knowledge-Artikels

005389424

 
Laden
Salesforce Help | Article