[SalesForce] How to automatically change the api name in apex and visual force

I need to change the API name of one of my fields to more clearly reflect its role in the system and I would like some way to automate the task as much as possible. There are, unfortunately, ~50 instances of it scattered around the visualforce and apex files. I could change it manually by commenting out the offending segments, changing the api name on the object and changing all the comments back but this is fraught with risk of missing one. There is also the option to ignore it but we have had issues with the name misleading people with what it is doing. Is there any such tool, plugin or otherwise to help with my task?

Best Answer

I would accomplish this with the Metadata Toolkit. Build a package to download all the Visualforce pages, classes, components, and triggers, and the object/fields in question. Change all the references at once and deploy the entire package as a change. All of the changes are applied as a single transaction, so as long as all the field references resolve, the code should deploy without any challenges. This will also help prevent missing any references to the field, since the deploy will fail otherwise. You can also try this in the Eclipse IDE, but make sure to disable automatic builds. I find this type of deployment to be trickier in the Eclipse IDE, but it is certainly possible to do with some care.