Find Active Dimensions for a Legal Entity in Ax2012

Hi,
Please use the below code to find the active dimension by legal entity. it will be useful when we do data upload.


static void getActiveFinancialDimensions(Args _args)
{
    DimensionAttributeSetItem   dimAttrSetItem; // Contains the number of dimensions active for a account structure ledger
    DimensionAttribute          dimAttr; // Contains the financial dimensions records
    DimensionEnumeration        dimensionSetId; //Record id for table that contains active dimensions for current ledger
   
    int dimAttrCount;
   
    //Get the record Id (dimension set id) for current ledger to find active dimensions
    dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();
 
    //Find the count of active dimensions for current ledger except main account
    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));
               
    //Find all the active dimensions for current ledger except main account and display them
    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);
    }
}

Thanks,
Vijaykarthik


Comments

Popular posts from this blog

x++ code to Generate cheque for vendor payment journal

Import Procurement Hierarchy / Categories with out code in ax 2012

Copy favorites From one user to another user - Ax 2012