microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
786 stars 621 forks source link

[Event Request] Codeunit 80 "Sales-Post" - procedure UpdateAssosOrderPostingNos - OnUpdateAssosOrderPostingNosOnAfterSetFilterTempSalesLine #19374

Closed MH1612 closed 2 years ago

MH1612 commented 2 years ago

Please add an Event OnUpdateAssosOrderPostingNosOnAfterSetFilterTempSalesLine in procedure UpdateAssosOrderPostingNos in Codeunit 80 "Sales-Post"

local procedure UpdateAssosOrderPostingNos(SalesHeader: Record "Sales Header") DropShipment: Boolean
    var
        TempSalesLine: Record "Sales Line" temporary;
        PurchOrderHeader: Record "Purchase Header";
        NoSeriesMgt: Codeunit NoSeriesManagement;
        ReleasePurchaseDocument: Codeunit "Release Purchase Document";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeUpdateAssosOrderPostingNos(SalesHeader, TempSalesLineGlobal, PreviewMode, DropShipment, IsHandled);
        if IsHandled then
            exit(DropShipment);

        with SalesHeader do begin
            ResetTempLines(TempSalesLine);
            TempSalesLine.SetFilter("Purch. Order Line No.", '<>0');

            OnUpdateAssosOrderPostingNosOnAfterSetFilterTempSalesLine(SalesHeader,TempSalesLine); <-- NEW EVENT

            DropShipment := not TempSalesLine.IsEmpty;

            TempSalesLine.SetFilter("Qty. to Ship", '<>0');
            if DropShipment and Ship then
                if TempSalesLine.FindSet() then
                    repeat
                        if PurchOrderHeader."No." <> TempSalesLine."Purchase Order No." then begin
                            PurchOrderHeader.Get(PurchOrderHeader."Document Type"::Order, TempSalesLine."Purchase Order No.");
                            PurchOrderHeader.TestField("Pay-to Vendor No.");
                            PurchOrderHeader.Receive := true;
                            OnUpdateAssosOrderPostingNosOnBeforeReleasePurchaseDocument(PurchOrderHeader);
                            ReleasePurchaseDocument.ReleasePurchaseHeader(PurchOrderHeader, PreviewMode);
                            if PurchOrderHeader."Receiving No." = '' then begin
                                PurchOrderHeader.TestField("Receiving No. Series");
                                PurchOrderHeader."Receiving No." :=
                                  NoSeriesMgt.GetNextNo(PurchOrderHeader."Receiving No. Series", "Posting Date", true);
                                PurchOrderHeader.Modify();
                            end;
                            OnUpdateAssosOrderPostingNosOnAfterReleasePurchaseDocument(PurchOrderHeader);
                        end;
                    until TempSalesLine.Next() = 0;
        end;

        OnAfterUpdateAssosOrderPostingNos(SalesHeader, TempSalesLine, DropShipment);
        exit(DropShipment);
    end;
    [IntegrationEvent(false, false)]
    local procedure OnUpdateAssosOrderPostingNosOnAfterSetFilterTempSalesLine(SalesHeader: Record "Sales Header"; var TempSalesLine: Record "Sales Line" temporary)
    begin
    end;
JesperSchulz commented 2 years ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 44285.