Root cause:

This error normally occurs closer to a Salesforce release window where the latest release was applied to your sandbox but has yet to be rolled out to your production instance.

For example, Spring 18' release was applied to your sandbox in Jan 2018 but is not going to be rolled out in Production until Feb 2018. If you create an Apex Class in your sandbox, the default version would be the latest version (42.0). Any attempts to deploy this Apex class to production would result in the error above. It is because your production instance was still on Winter 17' (version 41.0)

Resolution:

Edit your apex class in your sandbox and change its version to 41.0.

If you are using an IDE, you can change the version by editing the .cls-meta.xml file.
If you are using Salesforce setup UI, you can change version via Setup > Develop > Apex Class > Edit > Version Setting.

Note that this is only required during the short period where sandboxes and production instances are on different releases.

Are you still using change sets ? Try clickdeploy.io today and deploy Salesforce 10x faster.

Did this answer your question?