I am trying to understand how apiversions Interoperate with each other.

Lets say i have 2 classes 1 on version 54 and other on apiversion 55. If we call Class 2 methods from class 1 what API version will that method use apiversion 54 or 55.

Another scenario can be LWC/aura/Vf page on different API version then to controller class.

Last scenario is an external system calling rest API with version 46 and in trigger i have class with API version 54 then how it will work.

Just want an understanding of how salesforce handles different API versions.

1 Answer 1


Each unit is compiled according to its API version. However, when a transaction starts, the API version will be set according to whatever initialized the transaction. For example, a Visualforce page's API version determines the running version for the entire transaction when viewing a Visualforce page. If you read a debug log, the top line shows the API version for the entire transaction.

In most cases, everything works just fine, but be aware that some edge cases exist. For example, if you use a describe in a higher-versioned class, generate a SOQL query string, then return that to a lower-versioned API class, it can introduce fields that don't exist. The example I remember best was when I had a 28.0 class that generated a dynamic SOQL for a 27.0 class, and I would get a "LastViewedDate does not exist" error in the query. In other words, each unit behaves as if it were from that API version (because it is).

For this reason, I advise that you try to keep all of your versions the same, and schedule some time every few releases to test out updating the API versions to keep everything current. It's okay to not jump to the bleeding edge API version (especially during the next release preview cycle), just try to keep within 2-3 versions of current.

  • 1
    A lot of objects are newer and will introduce such versioning changes (more than fields in my experience).
    – Adrian Larson
    Apr 20, 2023 at 17:00
  • 1
    @AdrianLarson Yeah, that was just an example I recall from a while ago. Too many devs just accept the default versions instead of intentionally controlling versions, and it accumulates over time. My main point was that it is ideal to keep everything on the same version for stability reasons.
    – sfdcfox
    Apr 20, 2023 at 17:12
  • @sfdcfox just a query regarding issues for version 28 , 27 issue with LastViewedDate. If a Vf page with version 30 started that transaction then this issue wouldn't come? Apr 21, 2023 at 6:33
  • 1
    @ManjotSingh As a general rule, that's correct. The higher the starting API version, the less likely you are to run into version errors.
    – sfdcfox
    Apr 21, 2023 at 11:04

You must log in to answer this question.

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