Book Image

Mastering Microsoft Dynamics AX 2012 R3 Programming

By : Simon Buxton, Mat Fergusson
Book Image

Mastering Microsoft Dynamics AX 2012 R3 Programming

By: Simon Buxton, Mat Fergusson

Overview of this book

<p>Due to its interesting capabilities such as finance and supply chain management, business intelligence and reporting, project management, and so on, Microsoft Dynamics is one of the most widely used solutions adopted by many organizations across the globe. This book is a step-by-step tutorial that covers elements from the initial design through to development. Each concept is fully explained and demonstrated by the creation of a real-world project. You will learn some really useful, advanced development techniques such as extending your code with metadata and exception handling.</p> <p>This book is an invaluable tutorial if you are moving from another ERP system or language, or if you are a technical consultant with a desire to create efficient functional designs and business solutions.</p>
Table of Contents (21 chapters)
Mastering Microsoft Dynamics AX 2012 R3 Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Layers and models


The Layers and Models section is taken from the Packt Publishing book, Microsoft Dynamics AX 2012 R2 Administration Cookbook. It has been amended to suit a software development audience.

One of the key founding features of Dynamics AX was the ability to modify the software easily without locking the solution into a version. This was so advanced, even when the software was first released, that it would often be cheaper and faster to write the functionality in Dynamics AX than to upgrade the incumbent system.

AX not only had an outstanding IDE (the MorphX IDE) but also a solution to the problem of upgradability, change tracking, and management of solutions written by various parties; for example, Microsoft independent software vendors (ISVs)/Partners and the end-user/customer.

The solution to this was the technology called the layer system.

Layers

Layers segregate modifications (or the creation) of an application object's elements (for example, a field on a table or a control on a form). This allows Microsoft partners/ISVs and the customer to write a new functionality or change an existing functionality in a specific layer without directly modifying the standard software or the software supplied by the partner or ISV.

The following layers are available from the highest layer down:

Layer

Description

USR

The user layer is for end-user modifications, such as reports. It often has changes written by the development team of the end-user organization.

CUS

The customer layer is for modifications that are specific to a company.

VAR

Value-added Resellers (VAR) can make modifications or new developments to the VAR layer as specified by the customer or as a strategy of creating an industry-specific solution.

ISV

When an ISV creates their own solution, their modifications are saved in the ISV layer.

SLN

The solution layer is used by distributors to implement vertical partner solutions.

FPK

The FPK layer is an application object patch layer reserved by Microsoft for future patching or other updates. For more information, see Patch Layers [AX 2012] at https://msdn.microsoft.com/en-us/library/aa891248.aspx.

GLS

When the application is modified to match country- or region-specific legal demands, these modifications are saved in the GLS layer.

SYS

The standard application is implemented at the lowest level, the SYS layer. The application objects in it can never be deleted.

This information is taken from http://msdn.microsoft.com/en-us/library/aa851164.aspx.

Each layer has a patch layer, where SYP is the patch layer for SYS, and so on. The patch layer is used to ship hotfixes and service packs. A range of tools can be used to compare and merge code into a higher layer (that is, USR), where it has been changed by the patch.

Tip

Although it may seem logical to use the patch layer for updates to your system, this actually just adds more work and detracts from its goal of maintainability. It was sometimes useful before we had models, but with the model technology, it is used for a different purpose.

The current layer is set in the AX configuration utility, and to use any layer other than the USR layer, you need an access code, which Microsoft provides as part of your license.

When a change is made to individual elements (methods, fields, form controls, and so on), it is copied to the current layer. This copy then hides the element in lower layers. The compiler does this by looking down at the elements from the highest layer down—as if it were looking through the panes of a glass—as shown in the following image (which is taken from Microsoft TechNet):

The exception to this is if we modify an object that is already in a higher layer. In this case, the change is done in the higher layer—if there is any change in the current layer, it is not used. This is by design; if the change was made in the lower layer, it would not be used, as it would be masked by the higher layer change.

This means that your changes are protected, allowing you to merge the changes as required.

Commonly, your partner will develop features or customize AX in the VAR layer, and the end user (the customer) in either the CUS or the USR layer.

On rare occasions, the customer may use both CUS and USR. One example would be a global organization that has systems in several countries and employs an internal development team. In this case, the internal development team will develop the core system in the CUS layer, leaving the country to develop its own specific requirements in the USR layer.

Prior to AX 2012, the elements were not shredded to a sufficient level. In other words, forms were treated as one element and therefore copied in their entirety to your layer, should you simply add a field to a grid. This posed a problem for Microsoft because it limited the amount of add-on solutions that could coexist in a system without a developer merging the code.

This shredding of elements, into individual controls on a form for instance, exposed another problem for ISVs developing add-ons on AX.

An ISV would write their add-on in a specific layer: for example, SLN or ISV (in the previous versions, it would be the BUS layer). They would deliver their solution as an entire layer (which used to be a file ending in AOD) along with labels.

This, therefore, limited the number of ISV solutions you could use within your implementation without greatly increasing the complexity of implementing them.

The answer to this issue came in the form of models.

Models

Every element in a layer belongs to one model; if a layer does not have a model, the system will create a default model for it when a modification is made; for instance, the USR model. These are not normally used and, in my opinion, should never be used, as we cannot be sure whether this was intended.

A model exists in a specific layer, and elements in a layer can only belong to one model; this is by design and should not be thought of as a limitation. Thus, a model is a collection of elements in a specific layer.

If you import an add-on as a model, it will be imported into its original layer. The only thing you have to do is to synchronize, compile the application, and regenerate the CIL. This model can also be removed; again, all you need to do is synchronize, compile the application, and regenerate CIL.

You can then, in your layer and model, make changes to the add-on for your specific requirements; and when the ISV releases an upgrade, you simply have to import the model and use AX's tools to highlight the changes that may conflict with yours.

Models have many benefits, and I suspect more than what were initially intended when designed:

For ISVs, models create the following abilities:

  • Digitally sign the models

  • Ship the model in a way that is easy to deploy on their customers' systems

  • Send patches and upgrades to customers that are relatively easy to apply

For partners, the benefits of models are the following:

  • Easy alignment with development, deployment, and quality assurance processes

  • Simplified deployment of builds during the system's implementation

  • The partner can more easily use ISV solutions in their offering to their customers, which allows the partner to focus on their specific value offering

  • Environments such as live, User Acceptance Testing (UAT), and development are more easily kept aligned

There are advantages for customers too, which are as follows:

  • The ability to have more control of their system, where they can choose to install or remove add-ons with PowerShell commands. Earlier, the customer could only remove the whole layer and not add-ons within a layer.

  • Simplified deployment of internally developed solutions

  • As a side effect of the benefits to ISVs and partners, better value and quality of implementation are achieved, thereby reducing the risk

Tip

Don't fall for the trap of creating a model for each requirement because even with the object model's shredded control or field level, you will find overlaps (that is, changes required to a method across two requirements).

In our experience, partner and customer layers typically have the following models.

Typical partner (VAR) models are as follows:

  • The main functionality model (often named as a prefix and the customer name, for example, axp<CustomerName>)

  • Labels

  • Security roles

  • Add-on models

Here are the typical customer (CUS or USR) models:

  • The main functionality model

  • Labels

  • Customer-specific security roles

Note

A label file is a dictionary of label codes that that the Dynamics AX client uses to display labels and text in the user's language.

The reason a label file is in its own model is that the label file is not shredded into elements, and therefore, all labels in a label file exist in one model. Each party would normally maintain one label file, which has a three-letter name, and is therefore limited.