Thursday 22 August 2019

Get default financial dimension values through X++ code

Below is the way to get defaultdimensions of a record. In this example I'm using customer account .
In the same way you can try for other records(sales orders, purchase order etc)

Example 1
------------

        DimensionAttributeValueSetStorage           dimStorage;

// DimensionDefault is a RecId that combines all Dimension Values
            dimStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);
            for (i= 1 ; i<= dimStorage.elements() ; i++)
            {
                // Change the string "CostCenter" to whatever financial dimension you want
                if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Brand")
                {
                    info(dimStorage.getDisplayValueByIndex(i));
                }
                // Change the string "CostCenter" to whatever financial dimension you want
                if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Channel")
                {
                    info(dimStorage.getDisplayValueByIndex(i));
                }
                // Change the string "CostCenter" to whatever financial dimension you want
                if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Customer")
                {
                    info(dimStorage.getDisplayValueByIndex(i));
                }
                // Change the string "CostCenter" to whatever financial dimension you want
                if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Department")
                {
                    info(dimStorage.getDisplayValueByIndex(i));
                }
                // Change the string "CostCenter" to whatever financial dimension you want
                if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name ==        "ProductCategory")
                {
                    info(dimStorage.getDisplayValueByIndex(i));
                }
            }

Example 2
--------------

ProjTable                                       ProjTable;
DimensionAttributeValueSet           DimensionAttributeValueSet;
DimensionAttributeValueSetItem    DimensionAttributeValueSetItem;
DimensionAttributeValue                DimensionAttributeValue;
DimensionAttribute                         DimensionAttribute;

while select * from ProjTable
        where ProjTable.ProjId == "10005"    //  To display value for ProjectId "10005" only
join RecId from DimensionAttributeValueSet
        where  DimensionAttributeValueSet.RecId == ProjTable.DefaultDimension
join RecId, DisplayValue from DimensionAttributeValueSetItem
        where DimensionAttributeValueSetItem.DimensionAttributeValueSet == DimensionAttributeValueSet.RecId
join RecId from DimensionAttributeValue
        where DimensionAttributeValue.RecId == DimensionAttributeValueSetItem.DimensionAttributeValue
join RecId, Name from DimensionAttribute
        where DimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
    {
        info(DimensionAttribute.Name+"----"+ DimensionAttributeValueSetItem.DisplayValue);
    }

4 comments:

  1. I would recommend my profile is important to me, I invite you to discuss this topic... astrology career report

    ReplyDelete
  2. As a Bankruptcy Lawyer I am always asked; Can I get rid of my Student loan relief ​in bankruptcy? But over 99% of people with student debt and attorneys don't realize it's possible. Read on to find out how.

    ReplyDelete

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...