Data Conversion (in dax) is the process of migrating essential and often very large volumes of data, from a legacy system in to Dynamics AX.
I don’t see a point in even attempting to explain how important data is.... I think the importance of data in dynamics ax, can be compared to the importance of blood in a human!... bad data can literally cripple and bring the business/system to its knees...
A very knowledgeable person (I owe my ax career to him... ) once told me..
“Sh*t IN = Sh*t OUT” ... and that’s absolutely true...
I am sure you understand the importance of clean data by now.... if not shoot me a mail and I will tell you about some of the horrifying situations I have been through.
Dynamics AX, does have some very neat tools for data conversion.. the most popular being’ Excel Template Wizard’, this tool lets you export and import data in Excel ( .. obviously)
In this article, I wanted to cover the Data Definition Groups feature in AX. Def Groups is a very powerful and flexible method to import data in to ax, however it is Not widely used... mostly because of lack of understanding/documentation.
.. so what is a Definition Group?
Definition group can be considered to be a blueprint of the data that it to be exported/imported... in other words, a definition group identifies the tables, the fields and the format in which data is to be exchanged. In Dynamics AX, all exports must have a definition group...even the Excel import/export is done using definition groups (however this process is hidden from the user as the Template Wizard automatically create the def group). Also note that, contradictory to the popular belief, a single definition group can be used to export/import multiple tables.
Creating a definition group:
Fig 1:
Administration > Periodic > Data Export/Import> Definition Groups
Hit Ctrl + N on the Definition group list, which will pop up a Create Definition group form (as shown in Fig 1).
On the General tab, enter the definition group Id, Description (name) and the Definition Group Type. Currently there are 3 supported definition types:
1. Standard: use this type to export/import in binary or csv format. Data transfer using this type is the fastest, but it is not easy to modify the export files (binary/csv).
2. Custom: user definable file format, hence the data file is easy to modify.. however some of the advance import features (such as update old records and insert new, etc) are not available when using custom file types
3. Excel: easy to use (it’s easy to modify data in excel) and all advance features are available while importing the file. However excel export/import is the slowest of all file types and maximum number of records that can be imported/exported is 64K (approx)
Tip: Use excel when importing/exporting a small number of records (< 10000 records), else use the standard file type.
The Options and Include Table Groups tab are used to define the tables that are to be included in the definition group. By default all table groups are selected, hence all tables are by default included in the definition group.
Tip: if you would like to import/export a single table (or a few tables) then uncheck all boxes in the table groups and options tab.
Table Setup:
The meat of the definition group configuration is done in the Table setup form.
Select the definition group that is to be configured and click on the Table setup button.
The following is a screen shot of the overview tab on the table setup form.
• Name of Table: this field represents the table name that is to be included in the definition group. The table names are as represented in the AOT Data Dictionary.
• Export Status: make sure that this is set to “Export To”, if this field is set to any other value then the table won’t be included in any exports done later.
• Import Status: make sure that this is set to “Delete and Import” (clear the table before import) or just “Import”.
• Specify the path of the file that is to be used by this definition group (i.e. this is the file data is to be imported from or exported to).
• Use export Criterion: checking this filed will enable the “Export Criteria” button. This feature is used to define a export query, for example a definition group can be used to export a certain group of vendors
• Exclude Table: if this check box is checked, then the select table will be excluded from the definition group export/import.
• Occurrence id: this field specified the position in which this table appears if there are multiple tables in the definition group. For example if the export/import type is excel, then this field determines the tab on which the table appears.
• Validation level: This is a really useful option and helps ensures that business logic that is written on table validations methods is always enforced.
If this is set to Table, then the ValidateWrite method on the table is called. If it’s set to Field then both ValidateField and ValidateWrite are called.
Conversion Tab:
I think this is one of the most valuable features in definition groups. This feature enables developers to write scripts in x++ that are executed on every record imported.
In the example below, the script checks if a vendor account number is specified on the import file. If it isnt then a new vendor account is created using the number sequence setup in the system.
Note: this form is not a x++ editor, hence intillisense is not available here (i.e. a list of methods don’t appear when you hit ‘.’ ). Also notice the compile button.
This functionality can also be turned off by un-checking the” Run Conversion” check box.
Import Criteria:
This selection lets one define validation logic that is to be enforced on the definition import.
In the example blow, the validation logic will ensure that if the vendor name is “badVendor” then the record is not imported.
Log Files:
This section gives the last import/export details and also lets one specify a log file that is appended if there are any import errors.. This can be of immense use if large volume of data is being imported in batch.
Note: the above tabs are visible only if excel is selected as the file type.
General tab (only available if the selected file type is “custom”)
This tab lets one defile the character that is to be used to separate fields (a field delimiter).
The unique field helps ensure that duplicate records are rejected by the import routine.
Field Setup:
This form lets one define the fields that are to be included and their position, in the definition group,
References:
1. http://msdn.microsoft.com/en-us/library/aa834325(AX.10).aspx
2. Dynamics AX 2009 Help