Update sales line Line Financial Dimensions in Dynamics AX 2012 & D365 F&O X++

AX 2012 code
----------------------
static void RB_SLineFinDimensionUpdate(Args _args)
{
    SalesTable                          salesTable,salesTableUpd;
    SalesLine                           salesLine,salesLineUpd;
    CustAccount                      custAccount;
    DimensionDefault             defaultDimension,itemDefaultDimension,custDefaultDimension;


    salesTable   =  SalesTable::find('10000');
    salesLine    =  salesLine::find(salesTable.SalesId,1,true);

    if (salesLine)
    {
        itemDefaultDimension    =   InventTable::find(salesLine.ItemId).DefaultDimension;
        custDefaultDimension    =   CustTable::find(salesTable.CustAccount).DefaultDimension;

        defaultDimension        = DimensionDefaultingService::serviceMergeDefaultDimensions(custDefaultDimension,itemDefaultDimension);

        update_recordSet salesTableUpd
            setting defaultDimension =  custDefaultDimension
            where salesTableUpd.salesId == salesTable.SalesId;

            update_recordSet    salesLineUpd
                setting defaultDimension = defaultDimension
                where salesLineUpd.RecId == salesLine.RecId;

    }

}
D365 Code
-------------------
static void RB_SLineFinDimensionUpdate(Args _args)
{
    SalesTable                          salesTable,salesTableUpd;
    SalesLine                           salesLine,salesLineUpd;
    CustAccount                      custAccount;
    DimensionDefault             defaultDimension,itemDefaultDimension,custDefaultDimension;


    salesTable   =  SalesTable::find('10000');
    salesLine    =  salesLine::find(salesTable.SalesId,1,true);

    if (salesLine)
    {
        itemDefaultDimension    =   InventTable::find(salesLine.ItemId).DefaultDimension;
        custDefaultDimension    =   CustTable::find(salesTable.CustAccount).DefaultDimension;

defaultDimension        = LedgerDimensionDefaultFacade::serviceMergeDefaultDimensions(custDefaultDimension,itemDefaultDimension);;

        update_recordSet salesTableUpd
            setting defaultDimension =  custDefaultDimension
            where salesTableUpd.salesId == salesTable.SalesId;

            update_recordSet    salesLineUpd
                setting defaultDimension = defaultDimension
                where salesLineUpd.RecId == salesLine.RecId;

    }


}

Leave Comment

Your email address will not be published. Required fields are marked *