[X++] DMF/DIXF Custom generate method R2/R3

With the Data Import/Export Framework => DIXF (old: Data Migration Framework => DMF) we have the possibillity to import all kinds of data.
But when it comes to writing custom logic for imports, there is a small but significant change between Dynamics AX 2012 R2 and R3.

First of all, lets have a look what we are talking about.
I took the standard entitiy DMFDlvModeEntity for this example. The requirement was to import translations to the field Description also.

New Field in staging table

To accomplish this, I added a new Field called TxtNL to the staging table DMFDlvModeEntity to be able import my translated text for the language NL from my source file.
DMF AOT new field in table

Generate and getReturnFields Methods

Next, the method to generate the translation record has to be written.
We need to customize two methods:

  • generateTranslation (the new method)
  • getReturnFields (standard method, needs to be overriden if not exists)
Generate method

Those methods has to be prefixed with generate and will do the actual job.
And here comes the mentioned difference between R2 and R3:
In R2 we didn't need to specify attributes in this methods and had to create a field group on the table with the same name as the method.
In R3 we just need to specify the attributes in the method and the Framework will automatically recognize the method!
The method has always to be in the same schema:

  • Returning a container
  • Having parameter bool _stagingToTarget = true (to control if the code should run only when pushing the data from staging to target or also/just when importing to staging)
  • R3: Having Attribute DMFTargetTransformationAttribute(true)1
  • R3: Having Attribute DMFTargetTransformationDescAttribute("@labelID")2
  • R3: Having Attribute DMFTargetTransformationSequenceAttribute(Sequence)3
  • R3: Having Attribute DMFTargetTransFieldListAttribute([ListOfFields])4 DMF Generation method
getReturnFields method

This method needs to be overridden if not exists and is responsible to map the method to the fields later in the mapping setup. If the generate method does not update any fields in the target table, an empty case statement can be added.
DMF method getReturnFields

Customizing the target mapping

Under /Data import export framework/Area page/Setup/Target entities the button Modify target mapping will show the form to allow to modify the mapping as needed.
DMF Entitiy overview The Framework will automatically recognize our generation method by the attributes and will show it in the mapping:
DMF Mapping diagram If we want to change the order or the mapping itself, we can customize it at Mapping details:

Hope this helps!

Footnotes:

  1. Attribute DMFTargetTransformationAttribute(true): To make it a valid generation method for the framework.

  2. Attribute DMFTargetTransformationDescAttribute("@labelID"): The Description for the method.

  3. Attribute DMFTargetTransformationSequenceAttribute(Sequence): The sequence to execute.

  4. Attribute DMFTargetTransFieldListAttribute([ListOfFields]): The list of fields to be used insted of creating the field group on the table.

Robin

Software Engineer / Application Developer

Subscribe to robsCode

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!