web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :

How to get financial dimension values of Customers with the help of Accounting Structure using x++ in D365 FO

vishalsahijwani Profile Picture vishalsahijwani 196

Hi all ,


In my last post we used the names of financial dimensions in order to get the values from Customer Master.


In this post we will see how this can be achieved by using the name of the Accounting Structure configured to be used by the customer master.

Let's see how do we do it :-

class CalculateFinancialDimensionWActStruct
{
    public  Str1260 calculatefinancialdim(CustTable _custtable)
    {
        List                                                                                       dimensionAttributeList;
        ListEnumerator                                                                    listEnumerator;
        DimensionAttributeSetItem                                                 dimAttrSetItem;
        DimensionAttribute                                                             dimAttr;
        DimensionEnumeration                                                       dimensionSetId;
        DimensionService                                                                dimensionService;
        DimensionContract                                                              dimensionContract;
        AccountStructureContract                                                    accountStructureContract;
        Str1260                                                                                 dimvalue ;
        DefaultDimensionView                                                        defaultDimensionViewitem;

        dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();

        dimensionService = new dimensionService();

        accountStructureContract = new AccountStructureContract();
        accountStructureContract.parmName("RevenueDim");

        dimensionAttributeList = dimensionService.getDimensions(accountStructureContract);
     
        listEnumerator = dimensionAttributeList.getEnumerator();

        while (listEnumerator.moveNext())
        {
            dimensionContract = listEnumerator.current();

            select dimAttr
            join RecId from dimAttrSetItem
            where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
                dimAttrSetItem.DimensionAttributeSet == dimensionSetId
                && dimAttr.Name==dimensionContract.parmDimensionName();

            select firstonly defaultDimensionViewitem
                where defaultDimensionViewitem.DefaultDimension ==  _custtable.DefaultDimension
                    && defaultDimensionViewitem.Name ==dimAttr.Name;

            if (defaultDimensionViewitem.RecId)
            {
                dimvalue += '-'+defaultDimensionViewitem.DisplayValue ;
            }
            else
            {
                dimvalue += '-' ;
            }
            defaultDimensionViewitem.clear();
         
        }
        return dimvalue;
    }

Happy Coding !!!

This was originally posted here.

Comments

*This post is locked for comments