[SalesForce] way to upgrade api versions of all apex classes without manually updating each of them

I have an org with hundreds of apex classes, all of which have api versions ranging between 30-37. Is there an easy way to bring them all to the latest api version at once without resorting to manual updates?

Best Answer

WARNING


First of all, I would like to say, do this only if you are certain you have sufficient unit tests to catch anything that might break. Also, make certain you back up your code. I cannot stress this strongly enough.


You can do this pretty easily with any IDE, Salesforce DX, workbench, etc. The general process is either two or three steps.

First, download the files you want to update the API version for. Next, use a tool to "Find and Replace in Files". All major IDEs have this feature. Replace <apiVersion>.+</apiVersion> (a regular expression match) to the desired version. Third, if your IDE doesn't automatically deploy the changes, deploy the changes back to the server.


Force.com IDE (Search > File)

Find Version to Replace

Replace Version


Edit: 2020 Edition

You can use VS Code to do the same thing. Click on Edit > Replace in files, and use the Regular Expression option (far right button next to Search), and you can do this with VS Code. You need to perform a SFDX deploy afterwards.

VS Code Search and Replace

You can also do this with sed/awk and other *NIX (Unix, Linux) shell tools, too. Check the online documentation for your preferred tool.

Related Topic