D365 Finance & Operations and Dynamics AX Forum

 View Only

Customization in Dynamics AX: Overlayering vs. Extensions

By Nandita Nityanandam posted May 09, 2018 06:27 PM

  

Microsoft Dynamics AX offers a whole new range of features and capabilities that fit the needs of a variety of industries. However, often, organizations look for further customization in order for the solution to be more relevant to their business processes. Microsoft offers two methods to customize the Dynamics AX source code and meta data of model elements: overlayering and extensions.

overlays-extensions

Overlayering

Overlayering is a technique using which developers can customize metadata and the source code of a Dynamics AX model. However, it is essential that the overlaying model must belong to the same package as the source model and a layer that is higher than the source model. By creating an overlay model, you can make modifications in the existing source code and metadata, and use the CUS layer for customization.

By using the overlay approach, it is easy to extend or override standard functionality with less effort.  However, overlayering may increase the cost of upgrading the solution to the new version. It is also important to note that, after Spring 2018, all standard models of Dynamics AX will be hard sealed or locked and modifications will be possible only through extensions. 

As an example, let’s look at steps to create overlays for the Application Suite:


  • Create new model from Visual Studio: Dynamics 365 >> Model Management >> Create Model

overlayering1.png

  • Add required parameters in the listed fields, and make sure you are selecting the correct layer.

overlayering2.jpg

  • Since you are overriding objects, always use “Select existing Package” to select the appropriate package.

overlayering3.png

  • To complete the process, verify summary and click on Finish.

overlayering4.jpg
You can also override a standard object with the overlayering approach:

  • To override initValue(), customize “CustTable” as stated below:

overlayering5.jpg

  • The CustTable gets added in a project which belongs to the overlays model

    overlayering6.png
  • Add business logic before calling Super()

overlayering7.png
  • Build solution and verify result.

Extensions

Extensions are a relatively new technique that extend standard source code or metadata without affecting standard application artifacts. This is a great feature introduced by Microsoft with the newer versions of Dynamics AX like Dynamics 365 Unified Operations. Microsoft releases platform and feature updates at regular intervals for this cloud based solution, and having an extension-based solution makes it easy to apply the latest releases. Extensions -

  1. Greatly reduce the cost and efforts of an upgrade.
  2. Improve the performance of builds, test automation, and deployments.
  3. Allow you to separately build models or projects regardless of the application.
  4. Make it easy to apply new releases/updates/hotfixes without affecting customizations.

There are several ways to use extensions as mentioned below:

  • Create Extension Model: Since you are creating a new model, always use “create a new package” and select the appropriate package.
extension1.png

  • Class Extension
    • Class extension with COC
      • Assume MyClass is a standard class.
class-extension1.png

      • Extend source code by creating class extension.
    • class-extension2.png
      • Use COC (Chain of Command) to execute your business logic pre or post execution of base method.
class-extension3.png
    • Class extension: With class extensions, you can augment a class by adding methods and variables to existing tables, forms, and classes. To create a class extension using pre and post handler, Open class designer >> Select appropriate method >> Right click and select copy event handler >> select pre or post handler.

class-extensionb.png

      • In this example, we are extending the Shipment Confirmation process by validating setups prior to the shipment confirmation by using the pre-handler.
    • class-extension-b-1.png 
      • Once the shipment is confirmed, calling the shipment process by using the post handler.

class-extension-b-2.png
  • Form Extension: With a form extension, you can:
    • Add new controls
    • Enable or disable controls
    • Add a new data source
    • And change properties at the data-source level

  • Table Extension: Using a table extension, you can add new fields, field groups, indexes, mappings and relations. You can also extend the base methods using the event handler. Let’s look at some simple steps to add new fields in an existing table. 
    • Add new fields in an existing table: Right click on the table >> Select create extension
table-extensiona.png


    • Add required new fields in the table extension present under the “TabelExtension” node.

table-extensionb.png
    • Add required new fields in the table extension present under the “TabelExtension” node.

table-extensionc.png
  • Enum Extension: To extend the enum, make sure “IsExtensible = True” before you extend it.
          enum-extension.png
  • EDT Extension: You can extend EDT to modify the form help, label, string size, and help text.

  • Query Extension: You can extend a query to add range to an existing data source, add a new data source in an existing data source, or add fields in an existing data source.


Drive Innovation through Customization

The two approaches to customize and extend existing source code or metadata of Dynamics AX are truly remarkable. Although overlayering is a powerful tool to perform advanced customizations of metadata and source code, it may increase the cost of upgrading a solution to a new version. Also, with Microsoft restricting the use of overlaying, after April 2018, the only option you have to customize your Dynamics AX solution is by using extensions. Extensions allow you to add a new functionality to existing model elements and source code, create new model elements, extend existing model elements, extend source code using class extensions, or customize business logic – whatever is your requirement. Modify the Dynamics AX solution to meet the distinct needs of your organization, and drive innovation through customization.


jigal-patel.jpg

About the Author - Jigal Patel

Jigal Patel is a technical professional with over nine years of experience including five years working on Microsoft Dynamics AX. Currently, he is been involved in leading AX projects including implementation, customization, integration, upgrade and post implementation support.

Contributing Author: Malavika Nityanandam

0 comments
33 views

Permalink