Microsoft Dynamics AX development

Archive for July, 2013

DMF – Create custom entity mapping by using the wizard

When you create a custom entity, you must create a staging table, a project, a query, a class, and functions. You must always create the class and functions manually, but you can use one of two methods to create the staging table, project, and query:

  • Use the Create a custom entity for data import/export wizard.
  • Create the staging table and query manually




the query is a definition of a target table. You can add   relationships if required for mapping


The table suffixed with “Entity” is the staging table to use for mapping


the foreign key using RecId. The EDT generated, is a   string field representing the code


The class is where we can put business logic. For example, the EDT with   RecId need to be resolved

Creation by using the “Create a custom entity for migration

  • Data Import/Export Framework > Common > Create a custom entity for data import/export [Data migration framework > Common > Create a custom entity for migration] (2012)


  • Select a table that is related to the entity that you want to migrate, and then click Next
  • On the “Select code generation parameters”, the wizard will suggest names for the
    staging table, query, and class


  • On the “Wizard complete” page, click “Finish”. The Data Import/Export Framework
    opens the AOT and creates a project for the custom entity
  • If the table that you selected uses an extended data type (EDT), then you will be asked whether you want to add the ForeignKey relation from the EDT to the new staging table. Click Yes to create the ForeignKey relationship



Data import/export framework in AX 2012 R2


Data Migration Process

1) Prepare Source Data
The file must have a header, which includes the field names identifying each data column.

2) Define type of AX entity to be used
Define entities that will be loaded to AX. For example, Customers, Vendors…

3) Mapping and validation of source file fields to staging AX fields
The DMF tool will allow you to map each field from the source file to an AX field in the staging table. The DMF uses the field names to map the fields in the staging table.

4) Transferring data from source file to the staging table
Once fields from the source file have been mapped to AX fields in the staging table data should be ready to be transferred to the staging table.

5) Transfer of data from staging to target AX destination
Once data has been reviewed and validated in the stating table, the data is then moved to the target AXentity and AX records are created.


Data Migration Configuration

1) Determine entities – DMF > Setup > Target entities
There is a set of predefined entities. These entities also include procedures to move data from the staging table to the destination.

2) Define the source data format – DMF > Setup > Source data formats

  • Create a new data format
  • File format: delimited by a character or fixed
  • First row header: indicate if first row of the file, is a header row
  • Row / column delimiter: which character will be used to determine the end of the line / column
  • Text qualifier: indicates characters to encase text and commas
  • Regional settings: regional settings for the file
  • Role separator: used to indicate multiple entries, for example: 317-509 ; 508-999

3) Define the data format for each entity in the source environment
The data format can be a file that is delimited or fixed width, an ODBC data source, or a Microsoft Dynamics AX table

4/5) Define the processing group / Source to staging table

  • Create a new processing group
  • Entities:
    1. Create a new entity and select the source data format
    2. Run business logic: two flags to enable the check for AX business logic
    3. Sample file path: the path of the file
    4. Generate source mapping: maps the source file against the staging table. If you use AX column names as your header, the DMF tool will automatically try to do the mapping
    5. Modify source mapping: the user can review and modify the mappings
    6. Validate: the validation ensure that all fields in the source file are correctly mapped to the staging table
    7. View target mapping: this option can be used to validate the mappings
    8. Preview source file: the user can view a preview of the source file before the file is copied to the staging table
  • Get staging data: data is ready to be copied to the staging table. This button is used to start the process. A message indicate that the data has been copied to the staging table

6) Moving data from staging table to final ax destination
Select the “Copy data to target”.
Processing Group

Manage printer settings for SSRS Report in AX 2012

Goal: how to manage the printer settings for reports in AX 2012.

The following example is based on the new report Quality Orders in the Invent Module.


Create the SSRS Report

  • Report name:          InventQualityOrder
  • Contract name:       InventQualityOrderTableContract
  • Controller name:    InventQualityOrderTableController


Add new values to the BaseEnums:

  • PrintMgmtNodeType; add “QualityOrders”
  • PrintMgmtDocumentType; add “QualityOrders”


Create an extension of the PrintMgmtNode class:

public class PrintMgmtNode_QualityOrder extends PrintMgmtNode

public List getDocumentTypes()
    List docTypes = new List(Types::Enum);
    return docTypes;
public RefTableId getReferencedTableId()
    return tablenum(InventQualityOrderTable);


Modify the following classes:


1) Add the following code to the method “construct”:

case PrintMgmtNodeType::QualityOrdersWCH:
return new PrintMgmtNode_QualityOrderWCH();

A PrintMgmtNode class defines a level at which Print Management information can be associated.


1) Method getDefaultReportFormat()

case PrintMgmtDocumentType::QualityOrders:
return ssrsReportStr(InventQualityOrder, Report);

2) Method getQueryRangeFields()

case PrintMgmtDocumentType::QualityOrders:
fields.addEnd(fieldNum(InventQualityOrderTable, QualityOrderId));

3) Method getQueryTableId()

case PrintMgmtDocumentType::QualityOrders:
tableId = tableNum(InventQualityOrderTable);

The PrintMgmtDocType class represents the document types that are available in print management.


1) Method getNodesImplementation()


2) Method getParentImplementation()

case PrintMgmtNodeType::QualityOrders:


1) Method getDocumentTypes()


The PrintMgmtNode_Invent class is responsible for managing print management settings at the module level in the inventory module. Add the new document type in the method getDocumentTypes().


Create an extension of the FormLetterReport class:

class InventFormLetterReport_QualityOrder extends FormLetterReport
    InventTransType transType;
protected container getDefaultPrintJobSettings(PrintSetupOriginalCopy _printCopyOriginal)
    return new PrintJobSettings().packPrintJobSettings();
protected PrintMgmtDocumentType getPrintMgmtDocumentType()
    return PrintMgmtDocumentType::QualityOrders;
protected PrintMgmtHierarchyType getPrintMgmtHierarchyType()
    return PrintMgmtHierarchyType::Invent;
protected PrintMgmtNodeType getPrintMgmtNodeType()
    return PrintMgmtNodeType::QualityOrders;


Modify the FormLetterReport class:

1) Method construct()  

case PrintMgmtDocumentType::QualityOrders:
return new InventFormLetterReport_QualityOrder();

The FormLetterReport class controls the printing of documents.


Create the controller, which extends the TradeDocumentReportController class, which allows to manage multiple prints.

The following dialog aims to provide the possibility to choose printer settings that are different from the ones defined in the standard configuration (Inventory and warehouse management > Setup > Inventory and warehouse management parameters > Print management):

The dialog offers two scenarios:

– “Use print management destination” is flagged – in this case the system takes the settings from Inventory and warehouse management parameters

– Otherwise, the system takes the printer settings from the dialog (“Current print destination”).

In any case, it is necessary to overwrite the following methods in the controller:


protected void initFormLetterReport()
    printCopyOriginal = this.parmArgs().parmEnum();
    formLetterReport = FormLetterReport::construct(PrintMgmtDocumentType::QualityOrders);
    if (printCopyOriginal == PrintCopyOriginal::OriginalPrint)
        // Always use the print mgmt destinations when reprinting for the OriginalPrint case.


This method is called from the runPrintManagement method, for every selected journal.

protected void output()
    InventQualityOrderTableContractWCH rdpContract = this.parmReportContract().parmRdpContract() as InventQualityOrderTableContractWCH;
    //If the flag is not set, I set the current print destination in case of original/copy printing
    if (!rdpContract.parmUsePrintManagementSettings())
        formLetterReport.parmDefaultCopyPrintJobSettings(this.parmReportContract().parmPrintSettings()); formLetterReport.parmDefaultOriginalPrintJobSettings(this.parmReportContract().parmPrintSettings());
   // load the new setup for printing the report
   formLetterReport.loadPrintSettings(inventQualityOrderTable, inventQualityOrderTable, CompanyInfo::languageId());


Go to method populate() in table PrintMgmtReportFormat and add this line of code:


Finally go to:
Inventory and warehouse management > Setup > Inventory and warehouse management parameters > Print management
Here add a new node for the new report and set the print management settings.

For further information see also:

– SalesQuotationController class – for example – create a new SSRS report

Tag Cloud