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.
Open the AX client, go to the Data Import/Export Framework, then click Create a custom entity for data import/export.
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:
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.
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 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 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.
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.