Search This Blog

Monday, February 24, 2014

AX2012 Get dimension Values


To get the master Data for Dimension attributes we can use two service classes.
1. DimensionService
2. DimenisionValueService

we will see what Dimension Service class is providing
1. getActiveDimensionsFromLedger()- Gets active dimensions in current company which will return the DimensionContract class collection List.
2. getDimensions(AccountStructureContract _accountStructureContract)-Processes an incoming account structure contract and return a list of financial dimensions for a specific account structure.
3. getDimensionsAll()-Gets a list of all financial dimensions, which returns a A String list of dimension values using DimensionContract class.

we will see what DimensionValue Service class is providing
using this class we can create/Get DimensionValues for the specific dimension attribute.

Methods:
1. createDimensionValue(DimensionValueContract _dimensionValueContract)-Processes an incoming dimension value contract and creates a financial dimension value for a specific financial dimension.
2. getDimensionValues(DimensionContract _dimensionContract)- processes an incoming dimension contract and returns a list of financial dimension values for a specific financial dimension. and returns the list of the dimension values for that specific dimension attribute.

we can use this service classes and consume in any external application and call this service methods.


by using these two services we can get the dimension values easily.


static void Krishh_getDimensionValues(Args _args)
{

    List                            dimensionAttributeList;
    ListEnumerator                  listEnumerator;

    DimensionService                dimensionService;
    DimensionContract               dimensionContract;
    AccountStructureContract        accountStructureContract;

   
    dimensionService            = new dimensionService();

    accountStructureContract    = new AccountStructureContract();
    accountStructureContract.parmName("Account Structure - P&L");

    dimensionAttributeList      = dimensionService.getDimensions(accountStructureContract);

    listEnumerator  = dimensionAttributeList.getEnumerator();
    while (listEnumerator.moveNext())
    {
        dimensionContract   = listEnumerator.current();
        info(strFmt("%1, %2",dimensionAttributeList.elements(), dimensionContract.parmDimensionName()));
    }

}