Monday, December 21, 2020

Get default dimension name and description in Dynamics 365 finance and operations

I had requirement to get default dimension for Main account and when I look at internet I could see all of them  are so complex to get dimension name and description especially description. 

In fact we don't need all of them because in out of the box we have view which gives all this info by just one select query. if we have Default dimension and dimension. 


This view has method DefaultDimensionView.dimensionDiscription() which gives dimension description.

Please code for your reference, hope you find this useful!  

public static void main(Args _args)

    {

        #define.DimensionName("Department");

        DefaultDimensionView DefaultDimensionView;


        select firstonly DefaultDimensionView

             where DefaultDimensionView.Name == #DimensionName

                && DefaultDimensionView.DefaultDimension == 5637451520;//RecId of default dimension


        info(strFmt('Dimension Name: %1, Dimension description:%2', DefaultDimensionView.DisplayValue, DefaultDimensionView.dimensionDiscription()));

    }



No comments:

Post a Comment