Below is the code to get active financial dimension in ax 2012 or D365 using x++
DimensionAttributeSetItem dimAttrSetItem;
DimensionAttribute dimAttr;
DimensionEnumeration dimensionSetId;
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;
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
order by Name
where dimAttr.Type != DimensionAttributeType::MainAccount
join RecId from dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
dimAttrSetItem.DimensionAttributeSet == dimensionSetId
{
info(dimAttr.Name);
}
Enjoy :)
No comments:
Post a Comment