Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : o127ubUiVjUti1pqzozVFX

D365 Extensibility Attributes

Venkat Narayana M Profile Picture Venkat Narayana M 5

In D365 compared to Ax2012 we have Extension concept for customizing our developments compared to Over layering we are used to in Ax2012.

So, it is important to know how we can control event handlers and Extensions for our custom developments

To control the Extensibility of our Custom code we have three attributes

  • Hookable
  • Wrappable
  • Replaceable

 

Hookable:

As we know we cannot create event handlers on methods that are Protected or private

error-for-attributes.png

So, using Hookable attribute in our code helps to control the event handlers (Pre or Post) and Extensions for our methods

Example:

D365attributes_2D00_2.png

By using Hookable(true) attribute you can expose even Protected and private methods to event handlers (without Hookable attribute event handlers can be implemented only on public methods).

 d365attributes_2D00_3.png

Similarly, u can disable event handlers for your methods by using Hookable(false) attribute

Note: by using Hookable(false) attribute it overrides CoC(Chain of command) as well and those methods cannot have  extensions

Example:

 d365attributes_2D00_4.png

Extension class

 d365attributes_2D00_5.png

Replaceable:

If a method is replaceable, extenders can wrap it by using CoC, but they don't have to unconditionally call next. Although extenders can break the CoC, the expectation is that they will only conditionally break it. The compiler doesn't enforce calls to next.

Example:

Assume Core has implemented a custom logic for checking invoice prices

d365attributes_2D00_6.png

some other country wants to use custom logic by extending Core then there is no way to skip Core logic (without calling next) in D365.

d365attributes_2D00_7.png

Previously we could just comment Core code using over layering and implement our Custom region-specific code which is not possible now.

In those cases, we can use Replaceable(true) attribute.

d365attributes_2D00_8.png

d365attributes_2D00_9.png

By conditionally calling next we can completely skip core logic and run only region-specific custom logic.

 

 

 

Wrappable:

Wrappable attribute is used to control CoC (Chain of command) implementation for the methods

Wrappable(false) can be used for public and protected methods to prevent Extending the method using CoC.

d365attributes_2D00_10.png

 

Note: Private methods cannot have CoC implementation by default, with or without Wrappable attribute

Keep Coding

Original Blog Link : D365 -Extensibility Attributes | Learn and Share (wordpress.com)

 

Reference:

Attributes that make methods extensible - Finance & Operations | Dynamics 365 | Microsoft Docs

 

 

 

Comments

*This post is locked for comments