Showing posts with label getValue. Show all posts
Showing posts with label getValue. Show all posts

Monday, March 13, 2017

Get dimension name and value in Ax2012

Hi Guys,

Here is another code snippet to get Dimension value and name by dimension:

static DimensionValue Ale_getDefaultDimensionValue(DimensionDefault   _dimensionDefault , Name  _defaultDimensionName)
{
    DimensionAttributeValueSet      dimAttrValueSet;
    DimensionAttributeValueSetItem  dimAttrValueSetItem;
    DimensionAttributeValue         dimAttrValue;
    DimensionAttribute              dimAttr;
    Common                          dimensionValueEntity;
    DimensionValue                  dimValue;
    Name                                   dimName;
    container                           dimNameValue;
    ;
    dimAttrValueSet = DimensionAttributeValueSet::find(_dimensionDefault);

    while select DimensionAttributeValue from dimAttrValueSetItem
        where   dimAttrValueSetItem.DimensionAttributeValueSet   == dimAttrValueSet.RecId
    {
        dimAttrValue        = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);

        dimAttr             = DimensionAttribute::find(dimAttrValue.DimensionAttribute);

        dimensionValueEntity = DimensionDefaultingControllerBase::findBackingEntityInstance(curext(),dimAttr,dimAttrValue.EntityInstance);

        if (dimAttr.Name == _defaultDimensionName)
        {
            dimNameValue = [dimAttrValue.getValue(), dimAttrValue.getName()];
        }
    }
    return dimNameValue;
}