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 :
Small and medium business | Business Central, N...
Suggested Answer

Changing logic on drop ship sales orders to support adjusting quantities

(0) ShareShare
ReportReport
Posted on by 202

Hi. The default behavior in Business Central is to prevent you changing an order quantity is a sales order is associated. This makes no sense. It should instead allow you to sychronise the quantity to the purchase order if no shipment has occurred yet. I have found a raised event that allows you to have some influence - but it is unclear to be if I need to recreate all the other validations that would occur in the regular code or else break the system by saying isHandled =  true.

My AL code is below:

[EventSubscriber(ObjectType::Table, Database::"Sales Line", 'OnBeforeCheckAssocPurchOrder', '', false, false)]
    local procedure HandleOnBeforeCheckAssocPurchOrder(TheFieldCaption: Text[250]; var IsHandled: Boolean; var SalesLine: Record "Sales Line"; xSalesLine: Record "Sales Line")
    var
        PurchaseLine: Record "Purchase Line";
        ContinueChangeQtyMsg: Label 'Do you want to change qty in associated PO?';
    begin
        If (SalesLine."Quantity (Base)" <> xSalesLine."Quantity (Base)") and (xSalesLine."Quantity (Base)" = xSalesLine."Outstanding Qty. (Base)") then begin
            PurchaseLine.SetRange("Document No.", SalesLine."Purchase Order No.");
            PurchaseLine.SetRange("Line No.", SalesLine."Purch. Order Line No.");
            PurchaseLine.SetRange("Document Type", PurchaseLine."Document Type"::Order);

            If PurchaseLine.FindFirst() and (PurchaseLine."Quantity (Base)" <> SalesLine."Quantity (Base)") then
                If Dialog.Confirm(ContinueChangeQtyMsg) then begin
                    PurchaseLine.validate(Quantity, SalesLine.Quantity);
                    PurchaseLine.Modify();
                    IsHandled := true;
                end;

            //TODO Determine if we actually need to recreate additional checks and code to duplicate other checks performed by this function
        end;

    end;
 

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at

    Hello,

    If you think that this issue is caused by a bug, maybe you can file a support request to CSS and have us validate this in standard (assuming this is standard code).

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,742

#2
YUN ZHU Profile Picture

YUN ZHU 844 Super User 2025 Season 2

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 719 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans