Monday, 7 December 2020

event Handler financial dimensions Dynamics 365 AX DimensionAttribute

Event Handler financial dimensions Dynamics 365 AX

public static RecId assignDefaultDimensions(LedgerDefaultDimensionValueSet defaultDimension, str costCenter, str BusinessUnit)

    {
        DimensionAttributeValueSetStorage davss;
        DimensionAttribute dimAtrrCC,dimAtrrBU;
        DimensionAttributeValue dimAtrrCCValue,dimAtrrBUValue;

        davss = DimensionAttributeValueSetStorage::find(defaultDimension);
       
        dimAtrrCC = DimensionAttribute::findByName('CostCenter');
        dimAtrrBU = DimensionAttribute::findByName('BusinessUnit');

        dimAtrrCCValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrCC, costCenter, truetrue);
       
        dimAtrrBUValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrBU, BusinessUnit, truetrue);
       

        if(dimAtrrCCValue)
        {
            davss.addItem(dimAtrrCCValue);
        }

        if(dimAtrrBUValue)
        {
            davss.addItem(dimAtrrBUValue);
        }
        return davss.save();
    }

[FormControlEventHandler(formControlStr(VendEditInvoice, Code), FormControlEventType::Lookup)]
    public static void Code_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        Query                   query = new Query();
        QueryBuildDataSource    queryBuildDataSource;
        SysTableLookup          sysTableLookup;
        EcoResCategory          ecoResCategory;

        sysTableLookup = SysTableLookup::newParameters(tableNum(EcoResCategory),sender,true);
        sysTableLookup.parmUseLookupValue(false);
        sysTableLookup.addLookupfield(fieldNum(EcoResCategory, Code));
        queryBuildDataSource = query.addDataSource(tableNum(EcoResCategory));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();

        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        ce.CancelSuperCall();

    }

Thanks,
Vikas Mehta.

No comments:

Post a Comment

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...