You need to sign in to do that
Don't have an account?

Change Data Type from Picklist to Text field
Hi,
I want to get some suggestions on one of the issues I am having.
I want to change the data type for one of the custom objects. Currently, the field is picklist and is being used in multiple apex classes and triggers. I need to change it to Text field. I have come up with two solutions so far but I am not sure if any of these is the best practice. Please correct me if I am missing anything.
1) First solution is to comment the codes where the field is being used and then change the dataType and again uncomment back the codes. With this process, when I have to deploy it to production, it might be a bigger risk as it is being used in multiple places.
2) Second solution that I could think of is; creating a new field with datatype 'Text', and copying the existing records to this new field. Then replacing this new field with old field in the Apex classes and triggers.
Please suggest me if there are any other solutions.
Also, please suggest how would I revert this whole process if something goes wrong (any suggestion except the refresh of the sandbox would be appreciated).
Thanks in Advance!
Justin.
you should do the combination of both steps.
As you said you want to comment all the code where it has been used, do it then change the API name of that picklist field and create a text field with the same old name of the picklist field and copy the data from picklist to the text field and decomment and do all the necessary checks to let know every thing is going well.
By doing this you will have the old field and new filed , when you are very sure and no longer the picklist field necessary get rid of that.
If this answers your question make this as a solution and give kudos.
All Answers
you should do the combination of both steps.
As you said you want to comment all the code where it has been used, do it then change the API name of that picklist field and create a text field with the same old name of the picklist field and copy the data from picklist to the text field and decomment and do all the necessary checks to let know every thing is going well.
By doing this you will have the old field and new filed , when you are very sure and no longer the picklist field necessary get rid of that.
If this answers your question make this as a solution and give kudos.
Thanks a lot!
but make sure to have a list of where you are making the number of changes
Thanks for the tip! :)