To update Finanicail dimensions for partculer Vendor....we are going to use some of the tables and classes which are mentioned below.
In Microsoft Dynamics AX 2012 the financial dimensions are stored as a 64bit integer surrogate key in the database. For example, the following financial dimension combination of BusinessUnit = 001, ItemGroup = Service in AX it is represented as 22565424233.
For example im updating FD for vendor us102,
static void DefaultFinancialDim(Args _args)
{
DimensionAttributeValue dimAttrBUValue,dimAtrrCCValue,dimAtrrDepValue,dimAttrIGValue,dimAtrrProjValue; //table
DimensionAttribute dimAttrBU,dimAtrrCC,dimAtrrDep,dimAttrIG,dimAtrrProj;//table
DimensionAttributeValueSetStorage davss;//class
RecId defaultDimension;
VendTable vendTable;
davss = DimensionAttributeValueSetStorage::find(CustTable::find("US-102").DefaultDimension);
dimAttrBU = DimensionAttribute::findByName('BusinessUnit');
dimAtrrCC = DimensionAttribute::findByName('CostCenter');
dimAtrrDep = DimensionAttribute::findByName('Department');
dimAttrIG = DimensionAttribute::findByName('ItemGroup');
dimAtrrProj = DimensionAttribute::findByName('Project');
dimAttrBUValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrBU, "003", false, true);
dimAtrrCCValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrCC, "009", false, true);
dimAtrrDepValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrDep, "024", false, true);
dimAttrIGValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrIG, "AudioRM", false, true);
dimAtrrProjValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrProj, "000006", false, true);
if(dimAttrBUValue || dimAtrrCCValue ||dimAtrrDepValue || dimAttrIGValue || dimAtrrProjValue)
{
davss.addItem(dimAttrBUValue);
davss.addItem(dimAtrrCCValue);
davss.addItem(dimAtrrDepValue);
davss.addItem(dimAttrIGValue);
davss.addItem(dimAtrrProjValue);
vendTable = vendTable::find("US-102", true);
vendTable.DefaultDimension = davss.save();
vendTable.update();
info('updated');
}
}