HOW TO FIND DIMENSION NAME FROM A VALUE IN D365
We can use the below code to find the dimension value of a dimension from its name.
Eg. We can get the Costcenter or project code just by passing the value.
call the following method like
[localProjectValue,localProjectName] = Class::GetDimensionValue('Project', defaultdimension)
public static container GetDimensionValue(Name attributeName, RefRecID defaultDimension)
{
DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
DimensionAttributeValue dimensionAttributeValue;
DimensionAttribute dimensionAttribute;
;
select firstonly dimensionAttributeValueSetItem
where dimensionAttributeValueSetItem.DimensionAttributeValueSet == defaultDimension
join dimensionAttributeValue where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
join dimensionAttribute where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute &&
dimensionAttribute.Name Like attributeName;
return [dimensionAttributeValue.getValue(),dimensionAttributeValue.getName()];
}
Thanks,
Vikas Mehta,
We can use the below code to find the dimension value of a dimension from its name.
Eg. We can get the Costcenter or project code just by passing the value.
call the following method like
[localProjectValue,localProjectName] = Class::GetDimensionValue('Project', defaultdimension)
public static container GetDimensionValue(Name attributeName, RefRecID defaultDimension)
{
DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
DimensionAttributeValue dimensionAttributeValue;
DimensionAttribute dimensionAttribute;
;
select firstonly dimensionAttributeValueSetItem
where dimensionAttributeValueSetItem.DimensionAttributeValueSet == defaultDimension
join dimensionAttributeValue where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
join dimensionAttribute where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute &&
dimensionAttribute.Name Like attributeName;
return [dimensionAttributeValue.getValue(),dimensionAttributeValue.getName()];
}
Thanks,
Vikas Mehta,
No comments:
Post a Comment