Skip Purchase Order Document deletion in Business Central:
(1) Sometime business required Purchase Order Document in system when it is fully posted because in D365 BC purchase order document auto delete when it is fully posted.
(2) For doing this, call “OnBeforeDeleteAfterPosting” event for skip purchase order document to delete.
Source Code in AL:
|codeunit 50001 “Custom Functions-01”|
[EventSubscriber(ObjectType::Codeunit, Codeunit::”Purch.-Post”, ‘OnBeforeDeleteAfterPosting’, ”, true, true)]
procedure OnBeforeDeleteAfterPosting(var PurchaseHeader: Record “Purchase Header”;
var PurchInvHeader: Record “Purch. Inv. Header”; var PurchCrMemoHdr: Record “Purch. Cr. Memo Hdr.”;
var SkipDelete: Boolean; CommitIsSupressed: Boolean);
SkipDelete := True;
(3) After writing the above code and publishing the code and the system will auto handle the document skip functionality.