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, 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();
}
Thanks,
Vikas Mehta.
No comments:
Post a Comment