Hi experts,
Should the developer always use Chain of Command rather than event handler in X++?
Thanks,
Hi experts,
Should the developer always use Chain of Command rather than event handler in X++?
Thanks,
Hi Yuji,
I think its depend on the situation and functionality whether to use COC or event handler. In general COC is more powerful since you can access the form and class variables easily without much code.
Thanks,
Girish S.
Regaring pre- and post-method event handlers, they should be avoided whenever possible. CoC is a better way.
In my previous reply, I meant modeled events such as OnCreated.
"Always" is a strong word. The right answer is - as usual - "it depends". :-)
CoC is usually easier and more powerful, but event handlers have some benefits too. You can have a single handler method for multiple events and you also can add handlers at runtime, not just at design-time by attributes.
It also sometimes makes sense to create a single class with handlers for various objects (such as form controls of a single form) rather then having a separate extension class for each of them.
Thanks Komi, to answer my question, there shouldn't be any code written in pre or post event handler since COC is more powerful?
Hello Yuji,
Take a look at this.
community.dynamics.com/.../difference-between-coc-and-event-handler-in-d365