Export functionality does not export the model's Table constraints
This article provides a resolution for the issue that the Export functionality in Microsoft Dynamics AX 2009 does not export the model's Table constraints.
Applies to: Microsoft Dynamics AX 2009
Original KB number: 2464353
Symptoms
Microsoft Dynamics AX 2009 allows users to export product models, and import them into new product models, in either the same company, or new companies. When exporting product models however, Table constraints are not included. When importing the models, users must manually add the Table constraints.
Below possible scenario where Table constraints are not exported.
Open the menu path Product builder/Setup/Table constraints.
Create a new record with the following values:
Table constraint ID: InventTable
Name of the table constraint's table: InventTableCreate a new record in the lower grid with the following values:
Field name: ItemGroupId
Variable: ItemGroupIdCreate a new record in the lower grid with the following values:
Field name: ItemId
Variable: ItemIdSave the records and close the form.
Open the menu path Product builder/Common Forms/Product model details.
Create a new product model by selecting Ctrl+N on your keyboard and finish the wizard with selecting the Finish button.
Open the product model by selecting the Product modelbutton.
On the Product Model for select the Table constraints tab, create a new record with Constraint table id: InventTable and save the record.
In the Select variable group dialog, enter Basic in the Group dropdown and select OK.
Close the form so we are now back on the initial Product Models form.
Select the Functions button/Export product model and specifies a path and file name on the local hard drive.
Select OK.
Select the Functions button/Import product model and select the file created above during the export.
Select OK.
In step Delete following tables dialog, select the button No to all and then select OK.
A warning may be returned stating Group Basic and variable ItemGroupId and ItemId both already exist. This is expected.
Select the newly imported product model and select the Product model button.
On the Table constraints tab, the user notices the table constraints are not imported.
Cause
Table constraints are not included in the export logic for Product models. The Table constraints are not included in the exported data. This due to possible issues when Modeling variables exist with the same variable name.
Resolution
A code change will allow including the Table constraints during the export of a model.
Class method PBAExport.newPBAExport
:
Add code which makes the last lines look like this:
---------------------------------------------------------------------------------------------
export.addTmpExpImpTable(tablenum(PBARuleTableConstraintRef),false);
return Export;
---------------------------------------------------------------------------------------------
This includes the line Table constraints linked to the product model in the export and allows to import the table constraints.
More information
This workaround requires the Table constraints to exist in Product builder/Setup/Table constraints. This is important if table models are imported in other companies or on other databases. It does not allow exporting the table constraints (PBARuleTableConstraint
), and table constraint fields (PBARuleTableConstraintColumn
). This is due to validation limitations during import on existing variables with similar variable names. If required, you can manually export and import these two tables using the data export/import functionality in module Administration.