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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

How to merge Default Dimensions for Masters using x++ in D365 FO

Vishals786 Profile Picture Vishals786

Most of the times we get a requirement where we need to merge the dimensions from two areas in a single master.

For e.g In Sales Order Line the dimensions get populated from header but as soon as we select the Item Id the default financial dimensions are updated from Item Master and overrides the Sales Line Dimensions.

In order to achieve this merging from code we can use the below code in a data entity :-


        SalesTable                                             salestablefetch;
        SalesLine                                              saleslineupdate;
        CustTable                                              custtable;
        Str1260                                                 dimensionvalue;
        InventTable                                           inventTable;
        InvFinancialDimensions                       dimension = new InvFinancialDimensions() ;
        DimensionDefault                     defaultDimension,itemDefaultDimension,custDefaultDimension;

            select salestablefetch where salestablefetch.SalesId == this.SalesOrderNumber;
       
       
            inventTable = InventTable::find(this.ItemNumber);
            custtable = CustTable::find(salestablefetch.CustAccount) ;
           
           
           itemDefaultDimension    =   InventTable::find(inventTable.ItemId).DefaultDimension;
           custDefaultDimension    =   CustTable::find(custtable.AccountNum).DefaultDimension;
                             
        defaultDimension  = DimensionDefaultFacade::serviceMergeDefaultDimensions
                                                                  (custDefaultDimension,itemDefaultDimension);

        while select forupdate saleslineupdate
            where saleslineupdate.SalesId == this.SalesOrderNumber && saleslineupdate.ItemId ==                                                                            this.ItemNumber
        {

            if(saleslineupdate)
            {
                ttsbegin;
                saleslineupdate.DefaultDimension =  defaultDimension;
                saleslineupdate.update();
                ttscommit;
            }

This was originally posted here.

Comments

*This post is locked for comments