Thursday, September 4, 2014

AX 2012 - Retrieve a Dimension Value from a Index

Hi Guys

Below an useful code for retrieve a Financial Dimension value from an Index :

static DimensionValue DisplayDimensionValueFromIndex( DimensionDefault _DefaultDimension, int _level)
    {
        DimensionValue      ret;
        ;
       
        if( _defaultDimension && _level )
        {
            select RecId, Name
            from LedgerChartOfAccounts
            where LedgerChartOfAccounts.Name == curext()
                join ChartOfAccounts, DimensionHierarchy
                from LedgerChartOfAccountsStructure          
                where LedgerChartOfAccountsStructure.ChartOfAccounts == LedgerChartOfAccounts.RecId
                    join DimensionAttribute, DimensionHierarchy, Level
                    from DimensionHierarchyLevel
                    where DimensionHierarchyLevel.DimensionHierarchy == LedgerChartOfAccountsStructure.DimensionHierarchy
                       && DimensionHierarchyLevel.Level == _level;
   
   
            ret = DimensionAttributeValueSetStorage::find(_DefaultDimension).getDisplayValueByDimensionAttribute(DimensionHierarchyLevel.DimensionAttribute);
        }          
       
        return ret;
    }

Enjoy!

No comments: