Search This Blog

Friday, February 17, 2012

Ax2012 Get the Dimension values for the Main Account

Get the Dimension Values for the Main Account

static void krishh_dimensionCombValuesforMainAccount(Args _args)
    DimensionAttributeValueCombination  dimAttrValueComb;

    DimensionStorage        dimensionStorage;

    DimensionStorageSegment segment;
    int                     segmentCount, segmentIndex;
    int                     hierarchyCount, hierarchyIndex;
    str                     segmentName, segmentDescription;
    SysDim                  segmentValue;

    DimensionHierarchyLevel  dimensionHierarchyLevel;
    RefRecId recordvalue;
    DimensionAttributeValueCombination dimCombination;
    MainAccount  mainAccount;


    select  recid from dimCombination where  dimCombination.MainAccount==mainAccount.RecId
               && dimCombination.AccountStructure==recordvalue;

    dimAttrValueComb = DimensionAttributeValueCombination::find(dimCombination.RecId);
    setPrefix("Breakup for " + dimAttrValueComb.DisplayValue);

    dimensionStorage = DimensionStorage::findById(dimAttrValueComb.RecId);
    if (dimensionStorage == null)
        throw error("No dimension Specified for the Main Account");
    hierarchyCount = dimensionStorage.hierarchyCount();
    for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)
        setPrefix(strFmt("Hierarchy: %1", DimensionHierarchy::find(dimensionStorage.getHierarchyId(hierarchyIndex)).Name));

        segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);
        //Loop through segments and display required values
        for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)
            segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);
            if (segment.parmDimensionAttributeValueId() != 0)
               // Dimension Name
                segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;
                 // segment value- Dimension Value
                segmentValue        = segment.parmDisplayValue();

                //Description for dimension)
                segmentDescription  = segment.getName();
                info(strFmt("DimensionName:%1: Value:%2,Description: %3", segmentName, segmentValue, segmentDescription));


  1. Hi krishna,

    I want to display the financial dimension value in sales invoice report i.e., Worker( dimension 8). Actually the sales table takes only one default dimension. so how to display the worker dimension from defalut dimension in sales invoice report. Please reply me as soon as possible. Its urgent.


    1. Hi Sushmitha,
      I think it is employee dimension not worker Dimension, go to the desgígn and select dataset properties and click on query it will open the selection of dp class,click next it will load with the tables and there will be the section of dimension in that select check box of employee.


    2. Hi krishna,

      Thanks for quick reply. In sales order header financial dimension tab is there. In that I want to display the last dimension value( It is worker not employee). sales invoice dp class does not contain any dimension values, mat be it contains one default dimension value.


    3. Hi Sushmitha,
      You have to create new string field in salesinvoice tmp and get the dimension value and fill in the salesinvoiceDP class insert into that tmp method.
      you can see the following post to get the dimension value and description


    4. Hey all,

      I am sending out a note to those of you that have taken advantage of my Blog(,through skype,Chat..etc, that I have been making over the past couple of years, asking for a favor.

      It is that time of year 2013, and we are now announcing the nomination process for The Most Influential People in Microsoft Dynamics for 2013. I would really like to make the list this year, and I hope that I have influenced you all in my own little way.

      If you feel inclined, you can nominate me by sending an email with a persuasive explanation for the nomination to or through Twitter using the #dwtop100 tag.

      You can find more on the nomination process can be found here:

      Thanks in advance.

      Krishna Reddy Modugula | CGI |AX Technical Manager | Microsoft Solutions
      Lautrupvang 10, DK-2750 Ballerup | Denmark
      Phone: +45 44 78 40 00 | Mobile: +45 41 88 23 35 |

  2. Hi Krishna,

    I have a requirement where I would like to know from a MainAccount, what is the account structure this main account is linked to and what are the dimensions asscociated with this account structure.

    Do you have any sugesstions on how to achieve this.



Thanks for visiting my blog,
I will reply for your comment within 48 hours.