Wednesday, 13 June 2018

OnLookup event Handler and Assigning financial dimensions while importing in D365FO


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, true, true);
       
        dimAtrrBUValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrBU, BusinessUnit, true, true);
       

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

    }

2 comments:

  1. This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things. Thank you for sharing wonderful information with us to get some idea about it.
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore

    ReplyDelete