Thursday, 3 October 2019

HOW TO FIND DIMENSION NAME FROM A VALUE IN D365 CODE X++

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,

No comments:

Post a Comment

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...