microsoft / ALAppExtensions

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

Add event OnBeforeVendorLedgerEntryIsEmpty into table 288 "Vendor Bank Account" OnDeleteTrigger #26797

Open Flavioide opened 3 days ago

Flavioide commented 3 days ago

Describe the request

[IntegrationEvent(false, false)]
local procedure OnBeforeVendorLedgerEntryIsEmpty(var VendorBankAccount: Record "Vendor Bank Account";var VendorLedgerEntry: record "vendor ledger entry")
begin
end;

    trigger OnDelete()
    var
        VendorLedgerEntry: Record "Vendor Ledger Entry";
        Vendor: Record Vendor;
    begin
        VendorLedgerEntry.SetRange("Vendor No.", "Vendor No.");
        VendorLedgerEntry.SetRange("Recipient Bank Account", Code);
        VendorLedgerEntry.SetRange(Open, true);
        OnBeforeVendorLedgerEntryIsEmpty(rec, VendorLedgerEntry)
        if not VendorLedgerEntry.IsEmpty() then
            Error(BankAccDeleteErr);
        if Vendor.Get("Vendor No.") and (Vendor."Preferred Bank Account Code" = Code) then begin
            Vendor."Preferred Bank Account Code" := '';
            Vendor.Modify();
        end;
    end;

### Additional context

This event is usefull for anyone want to manage filters