In AX 2012 you can set the value for a specific dimension using code similar to what is below.
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();
}
dimAttrValue seems to be always true.
Hello!
There can be instances where the value isn’t found (dimAttr is a table buffer, so if a record isn’t found, this will be false), so at that point, an else statement could be used to set a predefined value if desired.
dimAttr = DimensionAttribute::findByName(‘MyDimensionName’);
The above line is looking for a record in the table. The code example simply doesn’t have an else condition to do something if a record is not found in the table.
Regards,
Taylor