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);
    }

}
}

Tuesday, 21 August 2018

Dimensions lookup based on dimension attribute name in D365

On Lookup Method


[FormControlEventHandler(formControlStr(EcoResCategory, EcoResCategory_DOMFinancialProductGroup), FormControlEventType::Lookup)]
    public static void EcoResCategory_DOMFinancialProductGroup_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        EcoResProductParameters     ecoResProductParameters;

        select USMFFinancialProductGroup from ecoResProductParameters;

        DimensionValueLookupHelper::lookupDimensionValues(DimensionAttribute::findByName(ecoResProductParameters.USMFFinancialProductGroup), sender, curExt());

//USMFFinancialProductGroup can be BusinesUnit, Department, CostCenter etc
    }


Reference

https://community.dynamics.com/ax/b/dynamicsax7knowledge/archive/2016/10/17/dimension-lookup-in-ax7