Change field Data Type without removing all references to said field in Controllers and Classes
I don't think there's any easy way to change a field that is being referenced in an apex class or trigger. There are two ways to get this done that I know of. Assuming you're working primarily in a sandbox:
- Comment out all the lines with that field in it in all classes and triggers.
- Modify the field.
- Deploy all the changed code and metadata to production
- Uncomment all those lines of code
- Deploy all the changed code to production
or
- Make a new field with a new name.
- Change every reference in your code to that new field.
- Deploy changed code and new metadata to production
- Move over any data from the old field to the new field
You could try to retrieve the object and all classes, triggers, vf pages components... with the metadata API by using the Eclipse or ant plugin. Then you are able to duplicate the field at the xml file of the object and replace the fieldname at all referencing entities. Finally you need to add the new field to the package.xml file.
After deploying the metadata back to the Org, you should be able to delete the original field.
A second round trip is needed, if the field should have the same API name as before.