Description
...
In the 3rd step you need to decide whether to subscribe to standard posting events.
...
Step 1: Define Steps
Define which Steps to collect
...
- Header Steps = OnGetReceiveOrderLines_OnAddStepsToAnyHeader
- Line Steps = OnGetReceiveOrderLines_OnAddStepsToAnyLine
...
Step 2: Handle collected Step values
Stage collected date in custom tables/fields
...
- Header Steps = OnPostReceiveOrder_OnBeforePost...
- Line Steps = OnPostReceiveOrder_OnHandleRegistrationFor...
...
Step 3: Standard posting
...
is triggered
Post and Clean-up staged data from 2nd step
...
TODO Verify sample code
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnRunOnBeforeFinalizePosting', '', false, false)]
local procedure MyOnPostingSalesReturnOrder_OnRunOnBeforeFinalizePosting(var SalesHeader: Record "Sales Header"; var SalesShipmentHeader: Record "Sales Shipment Header"; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var ReturnReceiptHeader: Record "Return Receipt Header"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; CommitIsSuppressed: Boolean)
var
OrderValues: Record "MOB Common Element" temporary;
MobRequestMgt: Codeunit "MOB NS Request Management";
HeaderRecRef: RecordRef;
begin
if IsNullGuid(SalesHeader."MOB Posting MessageId") then
exit; // not Mobile WMS posting or retry from Web Client
if (SalesHeader."Document Type" = SalesHeader."Document Type"::"Return Order") and (ReturnReceiptHeader."No." <> '') then begin
HeaderRecRef.GetTable(SalesHeader);
MobRequestMgt.GetOrderValues(SalesHeader."MOB Posting MessageId", OrderValues);
MyOnPostReceiveOrder_OnPostingSalesReturnOrder(OrderValues, SalesHeader, ReturnReceiptHeader);
end;
end;