lundi 27 février 2012

Find Active Dimensions for a Legal Entity [Ax2012]

This article focuses on getting the active dimensions for a Legal Entity. In Ax 2009, we could get the number of dimensions by using the enumCnt method on SysDimension enum and get the count. Here it is not that straight forward.
Following job will help you in getting the count and display their names;
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);
    }
}
image

Aucun commentaire:

Enregistrer un commentaire