function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

API Versioning on the Class

I am trying to understand the API versioning of classes when you make modifications in a newer salesforce release.  For example, if I create a class in spring 10 (say it was api version 22) and then I make a change to that class during the spring 14 release will the api for that class stay at api 22?

I notice there is a way to explicitly change the api from a drop down on the Version Settings tab of the class and I thought as long as I do not change that the oringal api version stays the same. 

However, I was told by an architect that if you change a class in the Spring release and that version was 22 for example, then it will compile under the Spring release version api 30 and be saved as api 30; however, I do not see that pick list change to 30 unless I explicitly change it.

Can someone put some clarity around what really happens?
To set the API and Apex version for a class or trigger:

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

Salesforce automatically chaned your version....but soome times your sandbox and production org is different version. The time of deployment you may get some  problem regarding versions....

In every release salesforce introducing some new relavant version change is very important.

I am not totally understanding.

In the Spring 14 sandbox I edited a class that was saved in an API version 20 and I added a line of code tha referenced the new spring 14 string method and I was able to save the class even though. It had an API version of 20.  I was expecting it to not save so it seems to that SF's compiler is working of API 30 even though I did not change the class API setting from. 20 to 30!  That is confusing to me and needed someone to put some clarity around what SF is really doing with regard to the API setting for classes and VF pages.

Thanks Tom