Background Story/ Problem Description:
Many time people ask how to display name/ description of a particular dimension like any Department, Cost-Center, Purpose, Business Unit and so on any Dimension. Here it goes as under:
Solution:
Every table, which is using dimensions have a field usually named as DefaultDimension, this field(what ever its name is), has relation with another table DimensionAttributeValueSet. So if you want to find the accurate field is most probably DefaultDimension or see relations node and find a relation with table DimensionAttributeValueSet. From there you would be able to see exact field for sure.
I short almost every standard table, which is using dimensions, have a field named as DefaultDimension. This field is basically an Int64 type field. Use the following code to display Dimension Value/Description:
DimensionAttributeValueSet dimAttrValueSet;
DimensionAttributeValueSetItem dimAttrValueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttribute;
RefRecID dimensionSetRecID;
Name attributeName;
;
dimensionSetRecID = 5637145444; //this number is basically from field DefaultDimension
attributeName = 'CostCenter'; //put here the name of dimension
dimAttrValueSet = DimensionAttributeValueSet::find(dimensionSetRecID);
select dimAttrValueSetItem
where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
join dimAttrValue
where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue
join dimAttribute
where dimAttribute.RecId == dimAttrValue.DimensionAttribute
&& dimAttribute.Name == attributeName;
info(strFmt("Cost-Center: %1----%2",dimAttrValue.getValue(),dimAttrValue.getName()));
Many time people ask how to display name/ description of a particular dimension like any Department, Cost-Center, Purpose, Business Unit and so on any Dimension. Here it goes as under:
Solution:
Every table, which is using dimensions have a field usually named as DefaultDimension, this field(what ever its name is), has relation with another table DimensionAttributeValueSet. So if you want to find the accurate field is most probably DefaultDimension or see relations node and find a relation with table DimensionAttributeValueSet. From there you would be able to see exact field for sure.
I short almost every standard table, which is using dimensions, have a field named as DefaultDimension. This field is basically an Int64 type field. Use the following code to display Dimension Value/Description:
DimensionAttributeValueSet dimAttrValueSet;
DimensionAttributeValueSetItem dimAttrValueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttribute;
RefRecID dimensionSetRecID;
Name attributeName;
;
dimensionSetRecID = 5637145444; //this number is basically from field DefaultDimension
attributeName = 'CostCenter'; //put here the name of dimension
dimAttrValueSet = DimensionAttributeValueSet::find(dimensionSetRecID);
select dimAttrValueSetItem
where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
join dimAttrValue
where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue
join dimAttribute
where dimAttribute.RecId == dimAttrValue.DimensionAttribute
&& dimAttribute.Name == attributeName;
info(strFmt("Cost-Center: %1----%2",dimAttrValue.getValue(),dimAttrValue.getName()));
thanx
ReplyDeleteThis works great! I created a Display method to use in an SSRS report and the values populated. My only issue now is getting it to work for the users. There seems to be a needed permission that I can't figure out. Have you used this with permissions and been able to get it to work?
ReplyDelete