This post is machine-translated. The original post in german language can be found here.

AX 2012: Show financial dimension using display method

Following display-method (created in the datasource of the form custtable) shows the  financial dimension Costcenter.

public display DimensionValue showCostCenter(CustTable _custTable)
{
    DimensionAttributeValueSet dimensionAttributeValueSet;
    DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
    DimensionAttributeValue dimensionAttributeValue;
    DimensionAttribute dimensionAttribute;

    #define.CostCenterDimensionName("CostCenter");
 
    if( !_custTable || !_custTable.DefaultDimension)
    {
        return '';
    } 

    dimensionAttributeValueSet = DimensionAttributeValueSet::find(_custTable.DefaultDimension); 

    select firstOnly RecId
    from dimensionAttributeValueSetItem
        where dimensionAttributeValueSetItem.DimensionAttributeValueSet == dimensionAttributeValueSet.RecId
    join DimensionAttributeValue
        where DimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
    join RecId from dimensionAttribute
    where dimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
       && dimensionAttribute.Name  == #CostCenterDimensionName
    

    if(dimensionAttributeValue && dimensionAttribute)
    {
        return dimensionAttributeValue.getValue();
    }

    return '';
}

Simpler version (see comments)

public display DimensionValue showCostCenter(CustTable _custTable)
{
    #define.CostCenterDimensionName("CostCenter");
 
    return ((select firstOnly DisplayValue from DefaultDimensionView
             where DefaultDimensionView.Name == #CostCenterDimensionName
                && DefaultDimensionView.DefaultDimension == _custTable.DefaultDimension).DisplayValue);
}
These post applies to following version:
Dynamics AX 2012

Rene Sparfeld 02/14/2014 12:50 | #1


Heinz Schweda 02/14/2014 17:32 | #2


 
 

 

This post is part of the series »Dynamics AX 2012 - Financial dimensions«

In Dynamics AX 2012, the handling of financial dimensions has changed. Both on the surface and the underlying data model.

In earlier versions you find one field - usually named dimension - of type array. Now you'll find a field derived from RecId called DefaultDimension (or similar).

In this series I want to specifically address these changes and present one or the other piece of code.

Show all posts from this series

RSS-Feed of this blog series


 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.