I started talking about Data Nomarlization in AX 2012 before. In this post we are going to see how you can generate the find method with a Snippet Code.

Many of the standard AX tools can help us with operational tasks, making them very efficient. One of these is called Snippets Code, which are features of the different modern IDE and in our case can help us write code much faster, while meeting certain prior conditions.

A classic example of this feature is the one that allows us to access a submenu that exists within the development environment of AX, which then allows us to create the parm methods with ease:

Remember that these methods typically have parameters. So do not expect to find them in a form or table methods.

To create a method similar to this we need to modify a couple of objects within the AOT: The first thing we will do is go to the class xppSource which explains these features and then create the following method:

Once we have written this format correctly we then go to the EditorScripts class, which contains the scripts corresponding to the MorphX IDE and we create a new method:

Later in the same class we will search the isApplicableMethod () and then add this information at the end:

We will compile and revise to ensure there are no errors.

To test the functionality go to a table with a single index and create a new method. Utilize the CustCollectionsPool table.

The method created should look like the following form:

Recall that the code templates are located in the standard xppSource class. So the first thing we did was to create a new method called findMethod which contains all the information required to view the find () method we are looking for. The method needs a table as argument, after which we write the sequence corresponding to the construction of the method, in the string form.

The list of elements that we are describing in this part corresponds to the fields which appear inside a single key in a table. Without a single key this functionality could not be carried out. This key is basically one that fulfills the following properties: it cannot be repeated and the fields that contain it are obligatory.

There are other rules in the construction of primary keys, which make up the good development practices in AX 2012, but in essence, a primary key here is also an SQL level, optimizing the queries and the process of the Information in large and complex databases.

The next step in building this feature is to create the link that accesses this information. The EditorScripts class is responsible for this part and therefore the one that is modified. The name of the method we created follows a certain format which should be underscored to make it understandable by Dynamics AX. If we have spelled the name correctly, this feature will produce the name automatically.

Finally we have modified the isApplicableMethod () method which ensures that the feature is only applicable to the table methods.

Sebastian Lazo - Ingeniero de Desarrollo

Sebastian Lazo

Ingeniero de Desarrollo