Wednesday, 4 March 2020

AX 2012 x++ set the default financial dimension

DimensionAttributeValue         dimAttrValue;
DimensionAttribute              dimAttr;
DimensionAttributeValueSetStorage davss;
RecId                defaultDimension;
davss = DimensionAttributeValueSetStorage::find(this.DefaultDimension);
dimAttr = DimensionAttribute::findByName(‘MyDimensionName’);
dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, “DimensionValue”, false, true);
if(dimAttrValue)
{
davss.addItem(dimAttrValue);
this.DefaultDimension = davss.save();
}

In case we need to set the Ledger Dimension
 LedgerDimensionFacade::serviceCreateLedgerDimension(LedgerDefaultAccountHelper::getDefaultAccountFromMainAccountRecId(MainAccount::findByMainAccountId(_mainAccount).RecId),_FinDim);
 

No comments:

Post a Comment