How to fix - "Illegal data conversion from original field" errors

At one time or another, most of you must have come across one or both of these errors,

Case 1:
Illegal data conversion from original field Table1.FieldX to Table2.FieldY: Unable to convert data types to anything but

character field type (0 to 4).

Synchronize database Cannot execute the required database operation.The SQL database has issued an error.

Case 2:
Illegal data conversion from original field Table1.FieldX to Table1.FieldY: Unable to convert data types to anything but

character field type (0 to 4).

Synchronize database Cannot execute the required database operation. The SQL database has issued an error.

The difference between these are that in the first case, the tables as well as the fields are different whereas in the second case the tables are same but fields are different.
Now, there are two scenarios when you may encounter the above error.


  1. While upgrading from one version of Dynamics AX to another version

  2. While importing a project or a stand alone xpo


These errors state that currently there is an already existing object in your system which has the same ID as the object that you are trying to upgrade or import.

So how do we fix these issues?

The fix is different depending on the reason why you are seeing these errors.

If you are performing an upgrade and hit this error, then you will carefully need to consider if it is actually possible

and not a rogue scenario.

To fix this you will have to change the ID of the offending object. The object can either be a table or a field.

While importing, the system checks the SQLDictionary system table to see if an object with the ID as what we are importing

exists in our system? If yes, it throws this errors.

To change the ID of the objects, we can use two methods on the ReleaseUpdateDB class, - changeTableId & changeFieldId

Both these methods are static.

Examples of their usage are,


// Parameters are tableID, Old FieldID, new FieldID, tableName, FieldName
ReleaseUpdateDB::changeFieldId(100,50001, 50002, "Table1", "FieldX");


// Parameters are old tableID, new tableID, tableName
ReleaseUpdateDB::changeTableId( 50001, 50002, "Table1");


The other case when you will see these errors is when you are importing some xpos. The reason why this could happen is that

you may have deleted the AOD file for a layer, then you try to import an xpo. In this case, your database still holds the

schema for tables from the AOD you removed. These were not cleaned up. So you may get an ID conflict error. In this case,

the solution is to go to your database and simply drop the offending table because we dont need it. No need to rename the

table or field here.

Hope this clarifies and helps understand these errors.

Comments

Popular posts from this blog

How to add empty ranges in query

Get selected records in Dynamics AX 2012

How to refer to form controls in code without setting the AutoDeclaration property in Dynamics AX?