In Dynamics 365 Finance and Operations (D365 F&O), the Chain of Command (CoC) design pattern allows you to extend the functionality of public and protected methods within classes. However, it is important to note that CoC cannot be used with private methods.
Private methods are intended to be used only within the class they are defined in, and as such, they are not accessible for extension through CoC. If you need to extend the functionality of a private method, you would typically need to:
Here’s a general example of how CoC is used with methods that are not private:
[ExtensionOf(classStr(BusinessLogic1))]
final class BusinessLogic1_Extension
{
protected str doSomething(int arg)
{
// Your custom pre-logic here
var result = next doSomething(arg);
// Your custom post-logic here
return result;
}
}
If you’re working with private methods and need to extend their functionality, consider discussing the possibility of refactoring with your development team or exploring alternative solutions like event handlers.