function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Christopher BoylesChristopher Boyles 

How to push Custom field API name changes?

Hi,
We have a custom Form, for which the page is written in VF and the controller is written in Apex. All of the fields the form is using are custom fields and are being referenced in the VF page and extension controller class. The API names were created poorly by the previous admin and needed to be changed.
In our Development Sandbox I edited the VF page and Controller class to point to another field, to break the reference, then I changed the API name of the field and then edited it back into the VF page and Controller class. This all worked fine, but was just a bit time consuming and after testing the form still worked in the Dev sandbox.
When it came to pushing it to the Testing environment however, the fields didn't update the old ones, they brought them in as if they were new fields. I thought Custom fields had an underlying Salesforce "ID" so that if something like this happens then it doesn't create new fields, it overwrites what has the matching ID?
Has anyone got any ideas on how I can fix it so that If I push to production I won't get a whole new set of fields instead of updating the old ones. This would mean migrating the data in about 60 fields for a few thousand forms to the new fields if I am unable to do this. As well as this I would need to go through and fix all of the reports and page layouts manually as well which I don't think we should have to do.
Thanks
Mohsinkhan PathanMohsinkhan Pathan
Hi,

This seems to be hectic task.I think You can use Destructive Changes xml  (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deploy_deleting_files.htm?search_text=destructive)to remove first, and use your usual calls to insert again.

Other way to do this is to extract your project using Eclipse IDE (atleast all the metadata contents where the field is referenced). Then with Eclipse comes a feature where you can search the text in all of your files, using that you can search your field and comment it out and save the code (obviously using Eclipse :) ). 
 
Once this is done; you can deploy your field to this org and then add the field to code and again save it. Once done you can delete the old field.

Hope this helps. 

Regards,
Mohsinkhan