2

I am unsure why each class has an API version. I know during each release they have added functionality therefore previous versions would not support this but I feel there must be more of a reason.

I also assume API versions is how they deprecate things and add new functionality. Is it best practice to update a class to the newest API if it has no dependencies?

10

To put it simply: The API version decides a couple of things for the Apex class - what fields you can access on a particular object or how you can implement certain mechanics.

And you're correct - API versions are used to introduce new features as well as deprecate old ones. Think of it as a way to decide what collection of functionality you want to use.

What is the best practice is an entirely different question - but to give you a very basic idea for this: Different API versions can give you all kinds of weird errors and behavior. From my personal experience, it is best to upgrade your API versions from time to time, so you have a consistent and recent version over all your classes and throughout your org.

See also: What are all of the reasons why Salesforce customers should upgrade the API version on their Apex classes, triggers, and pages?

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.