PO Item Line Unit Price update based on Trade Agreement in Dynamics 365

Hi,

PO Item Line Unit Price update based on Trade Agreement in Dynamics 365


Request: User wants to have option to update or not Purchase order Unit Price depends on current trade agreement. User may keep old price or update new price based on selection. This can be achieved via below two options in D365.

Solution 1: Custom made

I had over layered PurchLine table for this solution.

1.       Add New Project with model of App_Suite to customize PurchLine Table

2.       Go to PurchLine Table and Methods à setPriceAgreement method (This method determines whether prices are update or not while changing PO Qty)
//Add a Delegate for this method

delegate void PreservPurchPriceRefresh(Purchline purchlinePricePreserv,EventHandlerResult _res)
    {

    }
//Update the method
    public void setPriceAgreement(
        InventDim                               _inventDim,
        boolean                                        _doCallPriceDate     = false,
        PriceDiscPolicyCheckPolicy  _checkPolicy              = null,
        boolean                                        _initDateFields            = true)
    {
        EventHandlerResult result = new EventHandlerResult();

        //Calling the Delegate
        this.PreservPurchPriceRefresh(this, result);

        boolean res = result.result();

        //Block Price refresh by user selection
        if(res==false)
        {
        this.SalesPurchLine::setPriceAgreement(_inventDim, _doCallPriceDate, _checkPolicy, _initDateFields);
        }
    }

   Add Subscriber Method in any Class and build it.

[SubscribesTo(tableStr(PurchLine), delegateStr(PurchLine, PreservPurchPriceRefresh))]
    public static void PurchLine_PreservPurchPriceRefresh(PurchLine purchlinePricePreserv,EventHandlerResult _res)
    {
        DialogButton                            diagBut;
        boolean resUser=false; // Initial it should update the price
        if(purchlinePricePreserv.RecId)
        {
            str strMessage = "Do you want to update break down prices or not?";

            str strTitle = "Price update" ;

            diagBut = Box::yesNo(strMessage, DialogButton::No,  strTitle);

            if (diagBut == DialogButton::No)
            {
                resUser=true;
            }
            else if(diagBut == DialogButton::Yes)
            {
                resUser=false;

            }

            _res.result(resUser);

        }
      
      }

System will prompt below dialog while changing the PO qty and update price based on trade agreement setup.



Solution 2: Setting Manual Entry in Trade agreement evaluation policies in Microsoft Dynamics













Comments