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
softectonicsoftectonic 

Cannot change field type of a custom field...

Hi,

 

I changed a field type in an Org before deployment to another Org which contains an older version of the changed field and the field is referenced by a number of classes in the target Org. Surely during deployment error saying you cannot change field type of a custom field referenced in Apex class.. blah blah was received.

 

My question is what is the quickest and easiest way to fix the error beside commenting out the content of every file where the field is referenced in the target org?

 

Thanks in advance!

-S

MandyKoolMandyKool

Hi,

 

Unfortunately, there is no easy way as you have to comment out the file or you can only remove that field from the file temporarily; save the file and after that deploy your field and again add the deployed field to file.

 

The quickest 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 save it. I think this the quickest way to do this :)

 

softectonicsoftectonic

Thank you for your reply. In order to comment out the culprit field from the Apex classes I need to know the field name, unfortunately the error message produced by Ant Tool doesn't report the name, it reports only the Apex class in which the is field is referenced.

 

I need to run the script multiple times to know all the affected Apex classes. The tool only gives you one class at a time, would be nice if it reports all the classes in one run. Anyway thanks again!

MandyKoolMandyKool

Hi,

 

I am not sure whether i got what you are saying. But as per my understanding as you are changing the field in your source org then the field name will be same in the target org.

 

I have not used ANT much; but if you can use "Force.com IDE" then you can search the field name and comment out the code.

softectonicsoftectonic

We have multiple developers on the project building an App from Dev Org. I have the responsiblity of gathering their codes from Subversion and deploying to Sandbox with Ant Tool. Unfortunately the developers are not diligent about documenting field type changes or synching with Sandbox when the changes are made in Dev. I tend to discover them during migration. Hope this helps to clarify my issue. Thanks!