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;
}


Post a Comment


All Comments


No comments. Be the first one to comment on this post.

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 "buy me a coffee" link.
Join us.

Blog Tags