If you are working on objects (Tables or Classes) you haven’t designed then it is quite possible you could have an insight about these objects by reverse engineering them to either data model or object model. I came to know about an excellent reverse engineering tool in AX 2012, that’s why sharing here for others.
First of all create an empty project and add the tables or classes to this project you want to reverse engineer.
Then right click the project node, click Add-Ins then click Reverse Engineer.
Select Visio UML data model or object model depending on the elements you have added to the project (Tables or Classes). Give appropriate path to save the Visio file to.
Reverse engineering starts. After the processing complets Visio open up automatically.
In Visio under Model Explorer you can find your project node under Top Package. You can find your tables in the relevant table group node. AX categories each table created. The default value of table group property is “Miscellaneous”. In my case all the tables can be found under Miscellaneous node.
Drag the tables to the drawing pane one by one and see how Visio renders table fields and relationships automatically.
Often AX tables contain more than 100 columns which results in a tedious data model in which relationships are hard to view. To only view the relationships and hide the columns, you can suppress table columns (attributes). Right click on the table, click Shape Display Options.
Check attributes under Suppress section to hide the attributes. In this way you can view the relationships easily!
Conditional relations are used to filter records in parent or related table. We can define conditional relations by specifying fields in a table relation as:
- Field Fixed OR
- Related Field Fixed
Consider a scenario of a call center. The operator’s responsibility is to receive calls and get the orders for a shoe store. The operator first has to determine whether the order is of men’s, women’s or kid’s collection. Once the collection is determined then the operator has to determine which particular shoes the customer is ordering. It would be easier for the operator if the system filters shoes records based on the collection type [Men, Women, Kids]. In this situation conditional relations using a Field Fixed method fits the solution.
First, we will be creating two base enums such that CollectionType is like [Men(0), Women(1), Kids(2)]:
Then we will be creating three tables respectively for Men’s, Women’s and Kids’ collection. Note that all the three tables share the same set of fields:
Then we will be creating the final table for storing Orders. Two important fields must be added to the orders table in order to get benefit from conditional relations:
- ArticleCode – To lookup records into three different collection tables
- CollectionTypeId – To distinguish table relations defined for the collection tables
You can see in the picture how three relations have been defined. Each relation contains two fields, one used for determining the collection type and the other mapping to the respective collection’s Article Code field. Once all this is done, then now the system filters records for the user depending on the collection type the user has selected. See below how the system shows records from the men’s collection when CollectionType is set to ‘Men’:
Below is an example of CollectionType set to ‘Women’:
Below is an example of CollectionType set to ‘Kids’:
If you are not hitting the breakpoints you set in X++ code as expected then make sure that your code isn’t executed by the SysOperation Framework (formerly known as Business Operations Framework – BOF). If this is the case then you can force the AOS to debug your code in Dynamics AX Debugger by CLEARING the following check in Dynamics AX Development Workspace:
Tools >> Options >> Development >> Execute Business Operations in CIL
Moreover, make sure that Debug mode is set to:
Actually AX 2012 executes business logic as compiled .NET CIL to run faster. You can also debug your X++ code in Visual Studio Debugger by opening your method’s xpp file in Visual Studio then attaching to Ax32.exe process (Tools >> Attach to Process). In this way you will be debugging your X++ code in compiled .NET CIL mode. You can find your method’s xpp file under the following location:
C:\Program Files\Microsoft Dynamics AX\6.3\Server\AxaptaDev\bin\XppIL\source\<TableName\ClassName>.<MethodName>.xpp
Now if your X++ code runs under SysOperations Framework, then it will be invoked by any of the following methods: