Month: May 2016

AX 2012: Customize DIXF for cross-company import

Posted on Updated on

Purpose:

The purpose of this document is to demonstrate how we can customize DIXF (Data Import Export Framework) to import customers across the companies. The standard DIXF can only import records in the current company/legal entity. Customization will allow us to perform cross-company data import.

Business requirement:

Ability to import customers through DIXF across the companies.

Assumptions:

Data import export framework has been successfully installed.

Development:

1. Create a project to include the following objects:

Untitled

2. Add new field ImportCompany to DMFCustomerEntity table and set the properties as follows:

Untitled

3. Add new method existsInCompany to CustTable table and give the following definition:

static server boolean existsInCompany(
	CustAccount _custAccount,
	DataAreaId _dataAreaId)
{
    boolean found;

    changeCompany(_dataAreaId)
    {
        found = (select firstonly RecId from CustTable
         	    index hint AccountIdx
                        where custTable.AccountNum == _custAccount).RecId != 0;
    }

    return boolean;
}

4. Customize method insertUpdate of class DMFCustomerEntityClass to have the following definition. You can see that the modification has been wrapped within the BEGIN MOD and END MOD comments.

Untitled

5. Change the RunOn property of class DMFCustomerEntityClass to Server as shown below:

Untitled

6. Create new Data import export framework > Common > Processing group to import customers.

7. In the Select entities for processing group form:

  • select Customer for Entity
  • select Excel for Source data format
  • Generate source file

8. Prepare sample customer data to be imported as follows:

Untitled

9. In the Select entities for processing group form:

  • select the file in the Sample file path
  • Generate source mapping
  • Preview source file

10. You should be able to preview the sample data without any error:

Untitled

11. Change the current legal entity to any entity other than CEU to test the cross-company import scenario:

Untitled

12. In the Processing group form click Get staging data to import records in staging table:

Untitled

13. In the Processing group form click Copy data to target to import records to target table:

Untitled

14. Change the current legal entity back to CEU.

15. Click Accounts receivable > Common > Customers > All customers. You should be able to see the newly imported customers.

Untitled

As you have seen that we have successfully imported customers to CEU legal entity while being logged in to DAT legal entity, we can use the same customization to perform cross-company import. We just need to fill in the different legal entities in the ImportCompany column of the source Excel file.