Let's Keep it Simple: Data Migration

Let's Keep it Simple: Data Migration

September Blog Series: Innovation

Insights From: Vincent Ip (Fullscope Software Developer)

Microsoft Dynamics AX ERP introduced the Data Import/Export Framework (DIXF) feature in 2013 to simplify the process of data migration. The basic DIXF feature contains 150+ entities for end users to import data. These existing entities cover the majority of the important tables of data that can be imported into Dynamics AX. However, in order to import UOM conversions related data into AX, you must use the Custom Entity wizard feature to create a custom entity for the unit of measure conversions table.

Using the Custom Entity wizard does however present a challenge, because further customization is required for the new custom entity to work. Below is a step-by-step guide on how to create 1) the custom entity for the unit of measure conversions table using the Custom Entity wizard and 2) the customization required to pass the Best Practice check.

Read More: How Much Time (& Money) Do You Waste During an ERP Data Migration?

Open the AX client, go to the Data Import/Export Framework, then click Create a custom entity for data import/export.

 Click Next, and specify the table name. In this case it is UnitOfMeasureConversion. Click Nextagain. The wizard will fill out the entity table name, the entity query name and the entity class name. The only thing you need to fill out is the display menu item name. In this case, it is UnitOfMeasureConversion.

Click Next, this screen will let you select the fields for the staging table. In this case, all fields should be selected. Click Next again. This is the last screen of the wizard. Click Finish to exit this form. At this time, the component is built behind the scenes. Click Yes if the following screen comes up:

The process will complete in approximately a minute. After that, a private project will open automatically with the following items:
 
Notice the project is created inside the Private folder under project node. An additional EnumValue UnitOfMeasureConversion will also be created for the EnumObject DMFEntityType if you expand the enum.

There are a few things the entity table DMFUnitOfMeasureConversion must change in order to display the correct fields and properties. Remove the fields DisplayProductNumber1, EcoResProduct_DisplayProductNumber and UnitOfMeasure_Symbol. Rename the field Symbol and Symbol1 to FromUnitOfMeasure and ToUnitOfMeasure, respectively.

Correct any errors or issues until you only have the following Best Practice error.

Change the property on the Relations DMFExecution to match the following:

Right click and delete relation field for the relation UnitOfMeasure. Click OK to confirm the deletion. Rename the UnitOfMeasure to FromUnitOfMeasure and right click on it. Select "New Foreign Key" Single Field AlternateKey based. Delete the field UnitOfMeasure after the relation is established.

Create the new relation for the To UnitOfMeasure field. Rename the new relation ToUnitOfMeasure. Specify the properties based on the screenshot below. You might need to delete the field EcoResProduct after the new relation is created, as the system generates a new field automatically.

Read More: Technical Tip: Configuring Development Best Practices

Delete the relation fields in EcoResProduct, and then click the new relation by using the foreign key option, just like the FromUnitOfMeasure. Specify the properties as seen below. You might need to delete the field EcoResProduct after the new relation is created, as the system generates new fields automatically.

 The entity table DMFUnitOfMeasure looks like the below screenshot.

The next step is to modify the DMFUnitOfMeasureConversionEntityClass class object by double clicking on the class. A new method addStagingLink() must be added in order to create the relations between the staging table and the target table. If this method is not created, the records will not populate properly.

The method generateFromUnitOfMeasure() is created for you by the wizard. However, additional code must be added to complete it.

The method generateToUnitOfMesaure() is not created by the wizard. Therefore, you need to create a new method with the following code:

The method generateProduct() has also been created by the wizard. However, additional code must be added to complete it. Figure 15 shows the code sample.

Update the method getReturnFields() with the code highlighted in yellow below.

Open the method defaultEntityEx() on the table DMFEntity. The additional code will automatically populate the entity information when the target entity mapping is generated. Keep that in mind when you create the target entity.

Go to the Data Import/Export Framework Module, select Target Entities under Setup. Create a new target entity with the following information. (Please note: When you specify the value on the first Entity field, everything will populate for you except for the second Entity field. Validate this entity by clicking the Validate button, and close this form). Click on the Processing Group under Common to create a new processing group. In this example, the csv source data format is used to map the fields. The sample csv file will have the following fields and values:

Run the import by clicking the Get staging data button on the form. Click OK when the dialog box shows up. Click Run on the form to proceed to the next step. Click OK to import the data into the staging table. Run the process to bring the data into the target table UnitOfMeasureConversion by clicking the Copy data to target button. Select the proper job ID, and click OK. Click Run to proceed to next step. To populate the data into the target table, click OK to run this task as a batch. Then a dialog shows how many records are inserted into the target table. The records are inserted properly into each item.

You should now have a good understanding of how to use the Custom Entity wizard and how to customize the code to make the program fully functional. However, if you need additional help,  contact our experts today for more information on this and other Microsoft Dynamics AX ERP features.

 

Contact an Expert


Best Practices, ERP, Microsoft Dynamics, AX Technical Tip, Microsoft Dynamics AX ERP, Data migration, Microsoft Dynamics ERP, UnitofMeasure