Difference between chain of command and event handling in d365 f&o
Answer:
Difference between chain of command and event handling in d365 f&o
Chain of Command | Event Handling |
CoC allows you to create a new class and write code that runs before or after the base method. | Event handlers are used to add or modify the functionality of the standard application without changing the original code. |
CoC is usually easier and more powerful than event handlers. | Event handlers is complex compare to COC. |
The advantage of chain of command is you can share the same method variables in the pre and post (before/after next() call) or share the same tts block inside your COC method. COC also supports return value and parameter modification of the extended method in a much more readable manner. | Post Event Handler is static, does not allow you to have access to protected members of a class. Also you cannot add new method or class state via event handler, so CoC is way more powerful. |
CoC is a design pattern where a request is handled by a series of receivers. An extension class is used to wrap protected or public methods of classes, tables, data entities, and forms. You should be aware of some restrictions when wrapping methods:
- The wrapper method must have the same signature as the base method.
- When you augment form classes, only root-level methods can be wrapped, not methods that are defined in nested classes.
Wrapper methods in an extension class are required to always call next
so that the next
method in the chain and, finally, the original implementation is always called. This process ensures that every method in the chain factors into the result. The method must call next()
unconditionally.
Same Question
Difference between CoC and Event Handler in D365
Difference between Event Handler and CoC in D365
Difference between Event Handler and Chain of Command in D365 F&O
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of X++ Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.