Get default financial dimension values through X++ code
Views (4077)
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);
}
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);
}
This was originally posted here.

Like
Report
*This post is locked for comments