Microsoft Dynamics AX development

Scenario: I have to update the value “Fixed / Not fixed” for the financial dimensions in the main accounts with the DIXF.


First of all I’ve added a new field in the DMFMainAccountEntity in order to save the string with the “Fixed (= 1) / Not fixed (= 0)” values:


The format is the same as the value for the field DefaultDimensionStr. In the file I have for example: 1-0-0-0-0-0 (the first financial dimension has a fixed value and the other not).

I’ve added a new method in the class DMFDimensionHelper:

public static RecId generateFixedDefaultDimension(str _dimValueFixedString, DMFDataSourceProperties _sourceProperties, str _keyValue)
container                           dimAttributeList, dimValueFixedList;
int                                 j;
DimensionAttributeSetStorage        storage;
RecId                               defDimRecId;
DimensionFixed                      dimFixed;
DimensionAttribute                  dimAttr;

if (_sourceProperties && _dimValueFixedString)
//save the financial dimension from the string
dimAttributeList  = str2con(_sourceProperties.DimensionAttribute, enum2str(_sourceProperties.ChartOfAccountsDelimiter), false);
//save the values (fixed/not fixed) from the string
dimValueFixedList = str2con(_dimValueFixedString, enum2str(_sourceProperties.ChartOfAccountsDelimiter), false);

storage = new DimensionAttributeSetStorage(enumNum(DimensionFixed));

for (j=1;j<=conLen(dimAttributeList);j++)
//convert the string into enumeration
dimFixed = DMFEntityBase::string2Enum(conPeek(dimValueFixedList,j), enumNum(DimensionFixed));
//search the dimensionAttribute
dimAttr  = DimensionAttribute::findByName(conPeek(dimAttributeList,j));
//add the dimension attribute with the new value
storage.addItem(dimAttr.RecId, dimAttr.HashKey, dimFixed);
//save the new object
defDimRecId =;

return defDimRecId;

In the DMFMainAccountEntityClass, in the method generateMainAccountLegalEntity I’ve added the following code:

accountLegalEntity.FixedDimensions  = DMFDimensionHelper::generateFixedDefaultDimension(entity.FixedDefaultDimensionStrWPC,


Call two time the same report but with different design from controller class

Scenario: I have a report (MyReport) with two desing (DesignA and DesignB). The two designs are in the same report because the datasource is the the same and they are called from the same menu item.
The DesignA is always printed, but only in some cases I have to print the DesignB.

In the controller class, in the output method, I’ve added the following code:



Scenario: I have two textbox on the same line. Textbox A and Textbox B. Both have an hidden expression in order to hide the textbox if empty.


If the Textbox A is empty, maintains the white space in the layout.


The solution is to insert the two textbox in a rectangle.


In this way, the space of the textbox A is removed.


The entity DMFPriceDiscAdmTransEntity requires the field JournalNum.
I want to generate automatically this number.

In the class DmfPriceDiscAdmTransEntityClass I’ve added a new method:


If I start another “Copy data to target”, I hava already the JournalNum (and an existing Price journal) and the target records will be updated (if the journal is not posted).

In the method generatePriceDiscTableLink I’ve called the new method:



I have to create a dialog with SrsReportDataContractUIBuilder with:

  • a flag “MyFlag”
  • a button “MyButton”

When the flag is active, I have to disable the button.
When the flag is not active, I have to enable the button.

Create the UIBuilder class:

class MyUIBuilderClass extends SrsReportDataContractUIBuilder
    MyClassNameContract       contract;
    FormBuildButtonControl    myButton;
    DialogField               myFlag;

In the postBuild method, initialize the dialog with the controls:

Dialog                  dialogLocal;
Form                    form;
DialogGroup             dialogGroup;
FormBuildGroupControl   groupBuildControl;

dialogLocal = this.dialog();
contract = this.dataContractObject() as MyClassNameContract;
form = this.dialog().form();

myFlag = this.addDialogField(methodStr(MyClassNameContract, parmMyFlag), 

dialogGroup = dialogLocal.addGroup('My group name');
groupBuildControl = dialogLocal.formBuildDesign().control(
buttonBuildControl = groupBuildControl.addControl(FormControlType::Button, 
                     'My button name');


myButton.text(literalStr("A text for my button"));

//if you want to add a method for the button
myButton.registerOverrideMethod(methodStr(FormButtonControl, clicked), 
         methodStr(MyUIBuilderClass, methodForTheButton), this);

myFlag = this.bindInfo().getDialogField(this.dataContractObject(), 
         methodStr(MyClassNameContract, parmMyFlag));
myFlag.registerOverrideMethod(methodStr(FormChecKBoxControl, modified), 
       methodStr(MyUIBuilderClass, enableDisableMyButton), this);



In the method enableDisableMyButton:

public boolean enableDisableMyButton(FormCheckBoxControl _checkBoxControl)
    int ctrlId          = dialog.formRun().controlId('My button name');
    FormControl control = dialog.formRun().control(ctrlId);


    return true;


Insert the logic to bind the UIBuilder to the contract class, in the attributes:


The “Generate mapping” regenerate the mapping from staging to target.

When we click on “Generate mapping” we have two possibility:


Generate the mapping from scratch
It means that AX deletes and recreate the mapping. With this options all the (possible) manual modifications are deleted.

Generate the mapping from modifications
It means that AX adds the modifications to the existing mapping and the (possible) manual modifications are preserved. But, with this option we have a problem, if we have overwritten the method “getMappings()”.
AX creates duplicate mappings for those specified in this method.
For example, entity DMFProductEntity.

Method “getMappings” of the class (take into consideration the field AllocateMarkup):


Here we have the mapping BEFORE the “Generate mapping from modifications”:

Here we have the mapping AFTER  the “Generate mapping from modifications”:
aufnahme3The problem is that AX does not control if a  mapping already exists for the entity.

The method that duplicates the mappings is on the table DMFTargetXMLToEntityMap.generateMapping(). I’ve found a solution and added the following modification in order to control if the mapping already exists:


In this way we haven’t anymore duplicates.


I want to mapping one field in the staging table with multiple fields on the target table.
In the image, the field EmploymentType is mapped with two fields on the target table.

(For the example I’ve used the Employee entity)


To do this, you have to add a mapping in the code. For example, view the class DMFEmployeeEntityClass, method getMapping:


In the example, the field DMFEmployeeTargetEntity.PersonnelNumer is mapped with the HcmWorker.PersonnelNumber and the RetailStaffTable.StaffId.

Compile and refresh the mapping.


Tag Cloud