Is there a way to upgrade api versions of all apex classes without manually updating each of them?

Is there a 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?





Do you have a reason to want to do that? One of the points of the versioning is so that older code can rely on the behavior that existed when it was written and new code can opt-in to newer features by using the latest API version. Changing all the classes to the latest version would require some testing to be done to check that nothing has broken.
– Keith C
Aug 22 at 18:35




2 Answers
2



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.


<apiVersion>.+</apiVersion>



Force.com IDE (Search > File)



Replace Version



Firstly, do heed sfdxfox's warning. It is very important to backup your metadata before embarking on such a large scale update of the api versions.



Make sure you run all the test cases before and after to look for things breaking. They might break in strange and unexpected ways.



If you can, try this out in a scratch org first so it is easy to experiment and roll back if required.



René Winkelmeyer has created a SFDX plugin that can automate this process for you. It will either target the highest version in the target org or you can specify a target version.


sfdx muenzpraeger:source:api:set -a 41.0



Reading content of package directories

45 files have been set to API version 41.0.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế