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?
1 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.
-
How can i change
all the references at once
not using Eclipse? Commented Nov 18, 2013 at 16:04 -
2The ant toolkit downloads all the code/metadata at once. You can use any normal text editor, like notepad (I use Programmer's Notepad to find all references at once). You could also grep the code, write some sort of Perl script, etc. The exact tools you'll use are determined by your skill set.– sfdcfox ♦Commented Nov 18, 2013 at 16:36