[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.
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")
[1:1] - R3: Having Attribute
DMFTargetTransformationSequenceAttribute(Sequence)
[1:2] - R3: Having Attribute
DMFTargetTransFieldListAttribute([ListOfFields])
[1:3]
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.
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.
The Framework will automatically recognize our generation method by the attributes and will show it in the mapping:
If we want to change the order or the mapping itself, we can customize it at Mapping details
:
Hope this helps!
Footnotes: