5

My employer has a fair amount of Apex code that was written for us three to five years ago. We haven't been updating the API versions of the older classes and new code has been added, so we have quite a mix of API versions out there (versions 13-30).

This question got me to thinking about how best to bring the versions up to date. How should we approach this?

  • Update everything to the latest version all at once.
  • Update the oldest classes to some intermediate version(s) first. (if so, which)
  • Update classes to the latest version one at a time (recognizing that dependencies may force other updates)
  • Some other process not listed here

Note: Alan Morey has compiled a list of where to find the past Salesforce release notes here.

3
3

I think the way that I would approach this is one at a time, updating each class one by one to the latest API version and resolving issues as they arise. I'm guessing that the biggest changes you will face will be in the following areas:

  • Test data isolation - After (something like) version 24.0 of the API, tests no longer see all data in the database. If any of your unit tests rely on data in the instance, they'll likely start failing.
  • Inability to include both tests and code in the same class. In the latest API, tests must be in their own class and won't compile if they are included in a class that is not marked as @isTest at the class declaration
  • Make sure with or without sharing is explicitly declared on each class as what is implied without this keyword has changed subtly over the API versions.

I'm sure there is more but that's how I would approach it.

1
  • Also .. Note as of Summer 14, you won't need SeeAllData=true if your tests need to create custom pricebooks / pricebookEntries (i.e. v31 for the testmethod) – cropredy Jun 14 '14 at 0:00

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.