Tuesday 9 November 2021

Display individual financial dimension value in grid control in D365 FO x++

 To display inventory dimensions in the grid we have control of dimension display which can be set up as per the requirement. 

But there is no control in D365FO to display financial dimensions in grid control. 
There are 2 ways it can be done. 

1. Create display methods to display particular financial dimensions like the below method which displays division. I have seen many examples on the internet using multiple find methods but I prefer it by doing one query with joins to improve performance issues.

public display DimensionValue getDimensionDivision()
{
        DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;
        DimensionAttributeValue              dimensionAttributeValue;
        DimensionAttribute                       dimensionAttribute;
     
        select DisplayValue from dimensionAttributeValueSetItem
            join dimensionAttributeValue
            join dimensionAttribute
            where dimensionAttributeValueSetItem.DimensionAttributeValue    == dimensionAttributeValue.RecId 
                 && dimensionAttributeValue.DimensionAttribute                == dimensionAttribute.RecId
                 && dimensionAttribute.Name                                                == 'Division'
                 && dimensionAttributeValueSetItem.DimensionAttributeValueSet == this.DefaultDimension;;

       return dimensionAttributeValueSetItem.DisplayValue;
}

You can replace Division with whatever financial dimension you want to display.

2. The problem with the display method even with query is performance is never good so to solve that use views to display values using SQL rather than X++.

Create a view in AOT as below:
DimensionViewForDivision is the first view created which can be used across D365FO for any master table. The second view is where I connect DimensionViewForDivision with the Customer table.
Change the value in range for Name with FD you want.


The view can be used on a form, query or another view to display data in UI.



1 comment:

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...