Dynamics AX provides one of the best development environments of any ERP product. It is often easy to forget that the purpose of this environment is to create or extend functionality in order to satisfy a business requirement. The purpose of this chapter is to provide a short refresher on some of the core concepts and the preparation work required, before we start cutting code to put us on the right track to develop or extend functionality in Dynamics AX. This will enable your solutions to be maintainable and extendable, and minimize the impact on future updates and upgrades.
This chapter does not cover the installation and configuration of the required environments; it is assumed that this has already been done. We assume that our development environment has the AX client, management tools, and Visual Studio Professional 2013 installed. If you are using a version prior to cumulative update 8 (CU8), you will need to use Visual Studio 2010 Professional.
If we have to use Team Foundation Server (TFS), each developer must have their own development environment. Typically, we will have a virtual server as a single box AX installation.
In this chapter, we will cover the following topics:
In the first part of this chapter, we will briefly cover some key topics to refresh our memory. We will then cover some areas that we will expand on as we progress through the chapters. If you want to read in more detail about the technical infrastructure, the MorphX IDE, and development practices and patterns, refer to Appendix A, Efficient Design and Development with Microsoft Dynamics AX.
A good design is just as relevant to small change requests as it is for larger development. It has many attributes; some key points to consider are as follows:
Most of the functionality that we write in AX (a new solution or customization of an existing functionality) is data-based. We use forms to create, maintain, and view this data, tables to store and validate this data, and classes to act upon it.
The first part to design is the data structures. Even though these may evolve, a lot of attention is required here. A simple analogy would be to compare this to building a house; you can change the furniture, even add a room, but you cannot add a basement garage.
There is some guidance to be found here, that is, the structure will normally fit into an existing pattern that is already being used by AX. We normally expect to have the following types of tables in our solution:
InventTrans
is an example, which is viewed as a list of stock transactions.During the course of this book, we will be writing a solution based on a hypothetical case of a fleet management system as Contoso's internal development team. Based on the previous guidance, we can take the following simple requirement and quickly turn it into a data structure: we require the ability to view and maintain records of vehicles and their utilization.
From this, we can see that we will need to store a list of vehicles, probably of varying types, and then a record of their utilization will be attached to each vehicle. This leads us to the following structure:
Table type |
Example table name |
Description |
---|---|---|
Parameter |
|
The main parameters |
Group |
|
A list of vehicle types |
Main |
|
A list of vehicles |
Transaction |
|
The utilization records |
In this case, little thought was required as the requirement fits nicely into the standard AX patterns.
The naming was also straightforward: the organization's prefix is Con
, the module's prefix is FMS
, and the rest of the name comes from the entity name and the table type. You will see this type of naming throughout AX. As far as possible, we should be able to understand from the name alone what it is, what it does, how it does it, and why it does what it does.
The next part of the structure is the user interface, where we again have a set of templates that suit most circumstances:
TableGroup
property of the table.Based on the preceding templates, we can create the following forms for our example requirement:
ConFMSParameters
ConFMSVehicleGroup
ConFMSVehicleTableListPage
ConFMSVehicleTable
ConFMSVehicleTrans
We normally name forms after the table they act on, except for list pages. The last example does not really have a true template; the simple list is the closest. The data structures and forms are taken directly from how other parts of AX behave. This should always be a design goal as it ensures that our users' incumbent knowledge of AX is used, reducing the time needed to learn the new feature and minimizing errors.
Classes are used to store the main business logic. They are often used to handle user interface and table events as well. This allows the code to be reused and extended more easily.
The other key point is that we should also consider that we may want our solution to be available on mobile devices, and a careful thought about how we write the logic can make this much easier.
Classes in AX can be deployed as custom services that are consumed as WCF services in mobile or other Windows applications. This means that the logic should be simple to access, and have business logic in distinct classes, allowing the logic to be reused safely.
For example, we have a table with a status field that performs some validation and other events. We would write this in the data contract and service class pattern—a data contract to store the data to be acted upon and a service class to process the change. This can be used in a dialog form with the AX client or exposed as a service, allowing a mobile application to set the status.
18.117.11.240