General X++ Development

When should I use Chain of Command vs an event handler?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

When should I use Chain of Command vs an event handler?

SSunny Vasty75 reputation · answered Aug 13, 2026

I use Chain of Command when I am intentionally extending a method and need logic before or after that method.

I use an event handler when the framework already exposes an event that represents exactly what I care about and I do not need to wrap the method.

If CoC gives me the exact method I need, I usually prefer it because the execution path is easier to follow in the debugger.

If the event is the real business event I care about, use the event instead of wrapping some random method just because it happens to fire nearby.