3
votes

I'm having an issue on changing data type of a field in Dynamics CRM 2011 On Premise deployment. In my managed solution, name it "Solution 1", I have a custom field in contact entity: "new_usernumber" of type number (int). I want to change it to string as per new client's requirement (for new users they want to add prefix to it). I can uninstall the solution and deploy the new "fixed" managed solution, but this requires me to delete the value on my custom fields. Is there any better solution for this?

TIA

2

2 Answers

3
votes

There is no easy way to do this. If you don't already have data deployed in the instance using the managed solution I recommend deleting it and importing a corrected managed solution file.

There is no supported or unsupported process of changing the data type(or logical name) of a field without data loss. What you will need to do is add the new field and then write a quick update utility to copy the data from the old field to the new field.

Here is a great article on exactly how to pull off deleting a field in a managed solution. Note, if you are trying to preserve data you'll need to run the update after the step "Import devkeydetDeleteExample_1_1_HOLDING.zip"

Have fun...this is a pain, but certainly doable!

2
votes

A few months ago I recreated fields in a solution (from double to int). That was a huge mistake. I'm still not sure where things went wrong but they did go wrong. Not only did I lose the date. I managed to introduce errors in the meta-layer so our MVP had to sit dear help me get it running again. He wasn't happy. I wasn't happy. The customer wasn't happy (ex-customer today, mostly because of that).

So, my humble advice - don't do that. Declare a new field instead. If you have usernumber, keep it but start using userNumberString (or userString, userName etc.). My guess is you'll keep your hair longer that way.

And if you manage to succeed, please do tell. :)