3

Currently I am participating in existing salesforce development project. Today, I was going to deploy some classes after I made modification, I hit [Fail in Version Compatibility Check] and couldn't upload the certain apex class in Outbound Set.

So I browse through internet and follow this link and change version of that apex class to lower level 25 from 29. I search all other classes, all have <=27.

I check that class version in Production and is 25 and felt werid.

I wonder

1) that kind of version changes automatically happen?

2) It just happens when a user changes the existing version to something manually?

As I am still a newbie in SF development, pls share your idea or experiences.

| improve this question | | | | |
1

The apex version available changes with each release. So, with Winter '14 the, apex version 29 becomes available.

Unless you change it explicitly, classes retain the version that they have when they are created. So when you are looking at the other classes in production and seeing numbers less than 27, that probably was the latest version when those classes were initially developed.

Why you might be happy leaving a class on an older version of Apex

The benefit of this is that the language behaves the way that it did when the class was written and you don't need to do extensive regression testing.

Why you might want to set a class to a newer version of Apex

If you are working with a class developed against an older version of Apex, you may need to increase the version number in order to take advantage of features exposed in later versions of the API.

Why you might have API version trouble when deploying

By default new classes and triggers are created with the latest version of API. If you are working in a Sandbox this may be one version ahead of the Production org, depending on the release window. For example my sandbox is now version 29 (Winter '14) but Production is version 28 (Summer '13). In order to deploy a new class now I would need to save it with the lower version, version 28.

Also if you are deploying through ANT, Salesforce Migration Tool etc. then you need to ensure that the API version specified in your package.xml is at least as high as the the API version of what you are deploying.

How to set the API version

The api version is changed manually, either through the UI UI setting through the API

or if you are deploying through ANT or Salesforce IDE, by amending the metadata file which is called theapexclassname-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>25.0</apiVersion>
    <status>Active</status>
</ApexClass>
| improve this answer | | | | |
  • The class which version was changed to 29, was initially 25 when it was written. Due to your answer, someone might touch the class and change the version manually as class version can't be changed automatically. – kitokid Sep 18 '13 at 3:50
  • That sounds correct, if the class was version 25 before then it must have been manually changed to now be version 29. And version 29 won't deploy to a version 28 (Summer '13) instance. – Doug B Sep 18 '13 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.