Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am trying to move around 80 classes and visualforce pages from sandbox to production by using change set but i got an error

One or more components failed Version Compatibility Check. This change set contains components that require the "30.0" or higher platform version. Please select an organization with a platform version of "30.0" or higher, or remove all incompatible components.

I tried below from developer console,

List<ApexClass> apex = [select name,apiversion from ApexClass where apiversion=30];
for(ApexClass a:apex)
    a.apiversion = 29.0;
update apex;

Let me know if there is any other solution except changing the version manually by going to each class/page.

share|improve this question
add comment

2 Answers 2

There are two issues you are encountering:

1) You can't use DML on the ApexClass object. To do this programmatically you would need to use the Tooling API, the Metadata API, or Apex API.

2) The error suggests you have code that contains features that are not available in any API version below 30. You will either need to remove this functionality from the offending classes or wait until the target org gets updated to version 30.

If you wanted to change the version of Apex code in mass I would suggest some copy paste or a script to change the file versions locally, then use the Ant Migration Tool to deploy the changed metadata files to salesforce.

share|improve this answer
add comment

Probably you deployed the change set to another sandbox on v30.0 first, which made the change set v30.0 as well.

Make a new clone of the change set and deploy to production. Then it should work.

(do note that a fresh copy of the code will be made from your sandbox)

share|improve this answer
    
version was already 30. –  snehakem Apr 11 at 13:32
    
yes but that should not matter, unless there is indeed a Spring '14 component in your package. But then resetting the API to 29.0 on each component won't work either. Did you try my solution? –  guy Apr 11 at 13:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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