Skip Sales Order Document deletion in Business Central:
(1) Sometimes businesses required Sales Order Document in a system when it is fully posted because in
D365 BC sales order document auto delete when it is fully posted.
(2) For doing this, call “OnBeforeDeleteAfterPosting” event for skip Sales order document to delete.
Source Code in AL:
|codeunit 50001 “Custom Functions-01”|
[EventSubscriber(ObjectType::Codeunit, Codeunit::”Sales-Post”, ‘OnBeforeDeleteAfterPosting’, ”, true, true)]
procedure OnBeforeDeleteAfterPostingSale(var SalesHeader: Record “Sales Header”;
var SalesInvoiceHeader: Record “Sales Invoice Header”;
var SalesCrMemoHeader: Record “Sales Cr.Memo Header”;
var SkipDelete: Boolean;CommitIsSuppressed: Boolean; EverythingInvoiced: Boolean);
SkipDelete := True;
(3) After writing the above code and publishing the code and the system will auto handle the document skip functionality.