Using Chain of Command(COC) feature in Microsoft Dynamics 365 Finance & Operations


Microsoft has introduced the Chain of Command(COC) with Platform Update 9.

  • Developers can implement Chain on command across Classes, Tables, and Forms.
  • We are able to implement our custom business needs on Pre and Post functionality to extensible methods in a much easier and readable manner than the previously used event handlers, also we can extend the logic of public and protected methods without having to use event handlers.  
For an example, i am taking very small example of two cases as 

Case 1:  Before creating of production order we need to insert record in our custom table.
Case 2: After creating of production order we need to change its status from "Created" to "Estimated".


For above custom business need we need to follow below steps.

1. First we need to check Insert method of ProdTable and copy below highlighted code.


2. Create extension of ProdTable as shown below.

[ExtensionOf(tableStr(ProdTable))]
final public class ProdTable_Extension
{
    public void insert(boolean _dropEstimated, Common _childBuffer, boolean _expandBOMRoute)
    {
       Case 1:  Our Custom Logic before processing standard code. Working like Pre Event Handler
       // must call next when using Chain of Command pattern.
       next insert(_dropEstimated,_childBuffer,_expandBOMRoute);

       Case 2: Our Custom Logic after processing standard code. Working like Post Event Handler

    }
}
Default values of parameters are not required while implementing COC.

Previous
Next Post »

4 comments

Write comments