D365 - How to add OR change new/exisitng dimension value to a DefaultDimension using X++?

Here is how!


public static DimensionDefault addNewDimValueToDefautDimension(DimensionDefault defaultDimension, str dimName, str dimValue)
{
DimensionAttributeValueSetStorage   dimAttrValDimStorage    = DimensionAttributeValueSetStorage::find(defaultDimension);
   DimensionAttribute                  dimAttr                 = DimensionAttribute::findByName(dimName);
   DimensionAttributeValue             dimAttrValue            = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, dimValue);
        
   dimAttrValDimStorage.addItemValues(dimAttr.RecId, dimAttrValue.RecId, dimAttrValue.HashKey);
   defaultDimension = dimAttrValDimStorage.save();
   return defaultDimension;
}

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags