Friday, October 29, 2021

Difference between COC(Chain of commands) and Event Handler in D365

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.

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.

COC is nearly the same as pre and post-handlers, pre being before the next call and post after it.