Wednesday, 18 December 2013

Coding Related to Financial Dimension

Index : 

1. How to access Financial Dimension values in AX 2012.
=================================================================

How to access Financial Dimensions values in AX 2012:
   
 In earlier version, accessing dimension values was very simple like
                 CustTable.Dimension[0]      ==  Department  value  
                 CustTable.Dimension[1]      ==  CostCenter  value
                 CustTable.Dimension[2]      ==  Purpose       value

 In AX 60, since they have replaced Dimension EDT with RecId DimensionDefault we have to make use of Dimension helper classes to access values.So in CustTable you will find defaultDimension field which stores reference recId for DimensionAttributeSet.    

 I am referring Customer 1101 in CEU Company, Contoso Demo Data for illustration purpose. Note the dimension values for this customer as shown in below snap.


Refer the code to access the values.

static void DEV_Dimension(Args _args)
{
    CustTable                         custTable = CustTable::find("1101");
    DimensionAttributeValueSetStorage dimStorage;
    Counter i;
    
    dimStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        info(strFmt("%1 = %2", DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name,      
                               dimStorage.getDisplayValueByIndex(i)));
    }
}  

When you run the job, will see as below

No comments:

Post a Comment