Skip Purchase Order Document deletion when it is fully posted

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:

OnBeforeDeleteAfterPosting Source Code
codeunit 50001 “Custom Functions-01”
{
    trigger OnRun()
    begin
 
    end;
 
    [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);
    begin
        SkipDelete := True;
    end;
 
}

(3) After writing the above code and publishing the code and the system will auto handle the document skip functionality.


How to use FOR-TO loop statement in Microsoft D365
How to Find Base Application Object in BC D365
How to Create General Ledger Setup in D365 BC
How to Create Purchases and Payables Setup in D365 BC
Fiscal calendars, fiscal years, and periods– Microsoft Docs

Leave a Reply