Showing posts with label Active financial dimension in ax. Show all posts
Showing posts with label Active financial dimension in ax. Show all posts

Tuesday, December 15, 2020

Get active financial dimensions in ax 2012 or D365 using x++

Below is the code to get active financial dimension in ax 2012 or D365 using x++


          DimensionAttributeSetItem  dimAttrSetItem;
          DimensionAttribute  dimAttr;
          DimensionEnumeration dimensionSetId;

          int dimAttrCount;

          dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();

//Code to get count of active dimensions 

           select count(RecId) from dimAttr
                       where dimAttr.Type != DimensionAttributeType::MainAccount
                 join RecId from dimAttrSetItem
                        where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
                                   dimAttrSetItem.DimensionAttributeSet == dimensionSetId;

               info(strFmt("Total active financial dimensions for current legal entity: %1", dimAttr.RecId));

//Code to get active dimensions name

            while select * from dimAttr
                           order by Name
                           where dimAttr.Type != DimensionAttributeType::MainAccount
                     join RecId from dimAttrSetItem
                           where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
                                      dimAttrSetItem.DimensionAttributeSet == dimensionSetId        
            {

                    info(dimAttr.Name);

             }


Enjoy :)