CRM2011 Field Data Type Converter

Download: CRM 2011 Field Data Type Converter (1.0.4926.18530)

When trying to import a solution into CRM 2011, if you try import a field with the same name as an existing field but with a different data type, you will receive the following error.

Attribute <Attribute Name> is a <Existing Data Type>, but a <Import Data Type> type was specified.

Usually this happens when attempting to convert a field to a different type. In an environment where there is no data that cannot be lost, this is usually not an issue as one can simply

  1. Delete the existing attribute
  2. Import the solution again

In a production environment or an environment where data cannot be lost, this is not so simple as step 1 above will result in all data in the field being lost.

Enter the CRM2011 Field Data Converter…

The CRM2011 Field Data Converter does the following:

  1. Accepts a CRM Url and credentials, an entity and field, a destination type and various type specific parameters.
  2. Checks whether the supplied entity and field exist and what the field’s existing type is.
  3. Checks whether the source field can be converted to the destination type (see Conversions).
  4. Backs up the existing data.
  5. Deletes the source field.
  6. Creates a new field with the same name and new data type using the supplied type specific parameters.
  7. Populates the data back into the field (converted to the new type – see Conversions).
  8. Outputs a file listing the failures (conversion failures, save failures)

The CRM2011 Field Data Converter DOES NOT do the following:

  • Recover from catastrophic failures: As the data is backed in “in memory”, if a server, network or SQL instance goes down after storing the data and deleting the field, the DATA WILL BE LOST. BACK UP YOUR CRM DATABASE BEFORE RUNNING THIS TOOL.
  • Delete dependencies on the source field: If the source field cannot be deleted manually within CRM, it cannot be deleted by this tool. All dependencies on the field (forms, views, etc) must be manually removed before the tool is run and put back afterwards.

Conversions
  Destination
Boolean DateTime Decimal Double Integer Memo Money String
Source Boolean   * * * * * * *
DateTime   * *
Decimal * *   * * * * *
Double * * *   * * * *
Integer * * * *   * * *
Memo * # * * *   * *
Money * * * * * *   *
String * # * * * * *  
Key
* Convert.To<Type>(sourceValue, CultureInfo.CurrentCulture)
# DateTime.ParseExact(sourceValue, %/datetimepattern%, CultureInfo.CurrentCulture)
Advertisements

One thought on “CRM2011 Field Data Type Converter

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s