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
Karna_ShivaKarna_Shiva 

How would a developer change the field type of a custom field on account object from a string to an integer?

How would a developer change the field type of a custom field on account object from a string to an integer?


a. Remove all references in the code, make the change in the declarative UI, and restore the references with the new type.

b. Make the change in the developer console, and then the change will automatically be reflected in the apex.

C. make the change in the declarative UI, and then the change will automatically be reflected in the apex code.

D. make the change in the declarative UI, then update the field type to an integer field in-the apex code.
sandeep@Salesforcesandeep@Salesforce
(a)

You just need to remove it from all reference points and then may make change. 
other wise you would get error as below :
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Cannot change field type of a custom field referenced in Apex class or trigger: XXXXXX". 

Here XXXX is Apex Trigger or Apex class  name

Thanks 
Sandeep Singhal
Suraj Tripathi 47Suraj Tripathi 47
Hi Karna_Shiva,

You can change the field type of any field like this:
Go to setup->Select Object Manager->Choose Object Name->Click field and relationships->Choose Field name->Change type.
Now you can select Number type for integer.

If you find your Solution then mark this as the best answer.

Thank you!

Regards,
Suraj Tripathi