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.

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

Increase service timeout using Microsoft.Xrm.Client.dll CrmConnection class

The request channel timed out while waiting for a reply after 00:01:59.9844005. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation.

The error message above is caused by the maximum amount of time a single channel operation has to complete before a timeout fault is raised on a service channel binding being reached.

The fix for this, when not using Microsoft.Xrm.Client.dll’s CrmConnection class to connect to CRM, is well documented in several posts, (such as Dynamics CRM in the Field).

When using the Microsoft.Xrm.Client.dll’s CrmConnection class to connect to CRM, we can achieve the same thing by setting the Timeout property on the CrmConnection.

Microsoft.Xrm.Client.CrmConnection connection = new Microsoft.Xrm.Client.CrmConnection("ConnectionStringName");
connection.Timeout = new TimeSpan(0, 5, 0);
// Do something that will take longer than 2 minutes