11 Eylül 2014 Perşembe

AX 2012 - Get an individual dimension value from a LedgerDimension value

I used a data model about ledger dimension from a blog when I create this page. Unfortunately I couldn't understand code written at that blog and wrote this code:


 DimensionDefault                        d =  5637183219;
    DimensionAttributeValueCombination      dimensionAttributeValueCombination;
    DimensionAttributeValueGroupCombination dimensionAttributeValueGroupCombination;
    DimensionAttributeValueGroup            dimensionAttributeValueGroup;
    DimensionAttributeLevelValue            dimensionAttributeLevelValue;
    DimensionAttributeValue                 dimensionAttributeValue;
    DimensionAttribute                      dimensionAttribute;
   
    select dimensionAttributeValueCombination
            where dimensionAttributeValueCombination.RecId == d
        join dimensionAttributeValueGroupCombination
            where dimensionAttributeValueGroupCombination.DimensionAttributeValueCombination ==
                  dimensionAttributeValueCombination.RecId
        join dimensionAttributeValueGroup
            where dimensionAttributeValueGroup.RecId == dimensionAttributeValueGroupCombination.DimensionAttributeValueGroup
        join dimensionAttributeLevelValue
            where dimensionAttributeLevelValue.DimensionAttributeValueGroup == dimensionAttributeValueGroup.RecId
        join dimensionAttributeValue
            where dimensionAttributeValue.RecId == dimensionAttributeLevelValue.DimensionAttributeValue
        join dimensionAttribute
            where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute &&
                  DimensionAttribute.Name == "Project";
    info(DimensionAttributeLevelValue.DisplayValue);


Update:
The code at up doesn't worked for PurchTable defaultDimension field.
I got this code from Andesoft'un web site :

 DimensionDefault                        d =  5637169331;
    DimensionAttributeValueSet  dimAttrValueSet;
    DimensionAttributeValueSetItem  dimAttrValueSetItem;
    DimensionAttributeValue         dimAttrValue;
    DimensionAttribute          dimAttr;
    Common      dimensionValueEntity;
    DimensionValue  dimensionValue;
    DimensionAliasName  dimensionName;
   
    dimAttrValueSet = DimensionAttributeValueSet::find(D);
    while select dimAttrValueSetItem
        where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
    {
        dimAttrValue = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
       
        dimAttr = DimensionAttribute::find(DimAttrValue.DimensionAttribute);
        dimensionvalueentity = DimensionDefaultingControllerBase::findBackingEntityInstance(
        curext(),DimAttr,dimAttrvalue.EntityInstance);
        dimensionvalue = dimattrvalue.getValue();
        info(strFmt("%1 %2",Dimensionvalue, DimAttr.Name));
    }


2 yorum: