Tuesday, 28 August 2018

Chain of commands in D365

Using Chain of commands, we can  extend the logic of public and protected methods without having to use event handlers. When you wrap a method, you can also access public and protected methods, and variables of the base class.

First it goes to Standard method finds if there any extension method of same signature

and calls extension method then calls standard method if NEXT Word mentioned else

 It will not execute standard method. without NEXT word call

Rules


Ex :
[ExtensionOf(classStr(PurchLineType))]
final class PurchLineType_Extension

{


     public void initFromInventTable(
        InventTable     _inventTable,
        boolean         _searchPrice,
        boolean         _setAddressFromInventDim,
        boolean         _initDateFields,
        boolean         _executeOnlyIfProductIsFullySpecified)
    {
        InventTable     inventTable;
        purchline       purchlineLoc = purchline;
       
        if (purchlineLoc.itemId)
        {
            select DOMEndSupplier from inventTable
                where inventTable.ItemId == purchlineLoc.ItemId;

            purchlineLoc.EndSupplier = inventTable.EndSupplier;
        }

        next initFromInventTable(_inventTable, _searchPrice, _setAddressFromInventDim, _initDateFields, _executeOnlyIfProductIsFullySpecified);
    }

}
}

1 comment: