/// <summary> /// replace specific financial dimension value in DefaultDimension based on the LedgerParameters setup /// </summary> /// <param name = "_defaultDimensionFrom">DefaultDimension recId the value should be taken from</param> /// <param name = "_defaultDimensionTo">DefaultDimension recId the value should be assigned to</param> /// <returns>returns new DefaultDimension recId if conditions are met</returns> public static DimensionDefault replaceDefaultDim(DimensionDefault _defaultDimensionFrom, DimensionDefault _defaultDimensionTo) { if(!_defaultDimensionFrom) { return _defaultDimensionTo; } LedgerParameters ledgerParameters = LedgerParameters::find(); if (ledgerParameters.DepartmentSetFinancialDimension && ledgerParameters.DepartmentDimensionAttribute) { DimensionAttribute dimAttr; DimensionAttributeValue dimAttrValue; DimensionAttributeValueSetStorage davss; davss = DimensionAttributeValueSetStorage::find(_defaultDimensionTo); dimAttr = DimensionAttribute::find(ledgerParameters.DepartmentDimensionAttribute); DimensionAttributeValueSetStorage dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimensionFrom); DimensionValue dimValue = dimStorage.getDisplayValueByDimensionAttribute(dimAttr.RecId); dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, dimValue); if(dimAttrValue && !davss.containsDimensionAttributeValue(dimAttrValue.RecId)) { davss.addItem(dimAttrValue); return davss.save(); } } return _defaultDimensionTo; }
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Tuesday, May 25, 2021
Set Financial Dimensions by X++ code in AX 2012/Setting one Dimension value in the combination
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment