AX Developer Tips for Newbies: Part 1
I have compiled a collection of tips that seem to help new AX developers in my training classes, so I thought it would be good to share with the public. The selections in Part I are somewhat random and cover different areas of the Development Workspace.
Read more on X++ coding tips in AX Developer Tips for Newbies: Part 2
Tables in AX
Don’t forget about Field Groups
Any field that will be displayed in the interface should be in a Field Group.
Let’s take the BankAccountTable, Description Field Group for example. Note how the fields in the Field Group correspond to the fields in the Description group on the form.
Now, if we add a new descriptive field to the table, we can add it to the Description Field Group and it will automatically appear within the group on the form. No developer intervention required!
Note: Conversely, you cannot add a field/control that is not in the field group to this group on the form by dragging and dropping. This is because of the DataGroup property of the form group Group:Description. Removing the value from this property will allow you to add controls manually.
Forms in AX
Finding, Modifying, Fields & Methods
When first starting to learn AX, it may not be obvious how to find what form to modify and what fields and methods are used on a form.
From the application, open the form you need to work with. Right-click anywhere on the form and select Personalize.
On the Information tab, you will find the name of the form in the AOT, and clicking on Edit will open the form directly in the AOT.
On the layout tab with any field highlighted, you can see the table.fieldname in the System Name text box.
Note, if a table.fieldname ends with () as below, the field is actually a display or edit method and not a table field.
Dragging & Dropping Fields
When dragging and dropping fields from a Data Source to a Design Node, things don’t always end up where you ultimately need them. Trying to then drag the field up or down in the field list is not very precise, and it can be difficult to place fields in the order you need. A little known shortcut is to use the Alt key in combination with the Up/Down arrows. With the field you want to move highlighted, hold down the Alt key and press the Up arrow or Down arrow as needed to get the field in the correct position.
Reports in AX
Changing Parameters or Dialog:
If you have changed the parameters or dialog selections for a report, it will probably be necessary to reset Usage Data for users who have executed the report previously. If this isn’t done, when the users run the report it may appear as though your changes are not implemented.
Actually, if you make changes to a report or to its classes and it appears that your changes are not being picked up by client or server, any or all of the following steps may be needed, depending on what you changed and how your environment is configured. When all else fails, I do them all!
1. Deploy the report and make sure there are no errors
2. Reset usage data for any user who has executed the report (Tools/Options/Usage Data/Reset button)
3. Stop the AOS
4. Delete .auc files in the user’s appdata\local folder
5. Restart AOS
6. Restart SSRS
*For problems with extra blank pages on reports, please be sure to check out our blogs on the subject of blank page issues.
Classes in AX
What is super()?
The call to super() is used in relation with Inheritance. When one class extends another, it is often called the “child” class and the extended class the “parent” (even though this is not the correct Inheritance terminology…see https://msdn.microsoft.com/en-us/library/gg845237.aspx). However, if we keep in mind that parent classes can also be referred to as “Super” classes, this will help us in understanding the super() method call.
For example in AX, the InventMov_Sales class extends InventMovement. Note: The underscore in the class name is often an Inheritance indicator. The “child” or derived class has an override method canBeUpdatedRegistered. Specific logic has been added to determine if a sales order is Intercompany and can therefore not be updated. If not, then a super() call is made to the same method in the “super” or base class. See the screenshot below.
Be careful when adding code to override methods, as the placement of code before or after the super() call can cause very different behavior.
Troubleshooting in AX
When troubleshooting errors in AX, it can be helpful to place a breakpoint in the Info class, Add method, since all error messages in AX pass through this method.
We often have no idea what class/method is throwing an error, so with this breakpoint we have access to the call stack.
Hopefully, there are some helpful tips here for you. Stay tuned for more!