Microsoft introduced the new feature of extensibility which is known as Chain of Command (COC). This feature allows to use or call protected methods or members without making them hook able. Or We can say that it allows to extend the logic of public or protected methods without the need to event handlers. It is great feature for developers to do work with extension and avoid overlayering. It has made much easier for us to add pre and post functionality than previously used event handlers.

In Platform update 15 the concept of COC was implemented to class, tables and forms but with the release of October 2018 they have extended this capability and introduced COC  across data source fields/methods which was previously missing.

Note: If you want to use COC you need to declare your class as final and your method should always contain next keyword.

The next keyword behaves like super and it defines execution of your extended code. If next is called after your code then it will behave like Pre handler which means your logic will execute first then original method logic. If next is called before your code then it will behave like Post handler which means original method logic will execute first then your custom logic.

Let's take a example of item group setup. Suppose I want to create new a item group and set it name value on default basis at a time of modifying item group id field. But we want to execute first original method logic then our custom logic. So here we will follow post event handler concept using chain of command.

Create a new class which will be final and add below logic in it. Remember you need to create new class for every object you want to extend.