ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request]: Table 179 "Reversal Entry" - OnBeforeCheckBankLedgerEntryOpen and OnBeforeCheckBankLedgerEntryStatement

Open MortegaITB opened this issue 7 months ago • 4 comments

Why do you need this change?

We need more flexibility when working with Bank Account Ledger Entries in custom processes and integrations.

Currently, the standard procedure CheckBankAcc enforces strict validations that trigger errors when:

The entry is not open The entry has a Statement No. assigned

These validations prevent us from reusing standard logic in scenarios such as:

Automated integrations Data correction processes Controlled reversals or reprocessing Custom financial workflows

Since these errors are hardcoded and not extensible, we cannot override or bypass them using standard event subscribers. This forces us to duplicate standard logic or modify base code, which is not maintainable.

Describe the request

We request to add event publishers (integration events) before the following validations in the procedure CheckBankAcc: if not BankAccountLedgerEntry.Open then Error( Text006, BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry."Entry No."); if BankAccountLedgerEntry."Statement No." <> '' then Error( Text007, BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry."Entry No.");

Suggested implementation:

Add events like: OnBeforeCheckBankLedgerEntryOpen(BankAccountLedgerEntry: Record "Bank Account Ledger Entry"; var IsHandled: Boolean) OnBeforeCheckBankLedgerEntryStatement(BankAccountLedgerEntry: Record "Bank Account Ledger Entry"; var IsHandled: Boolean)

Alternatives Evaluated:

We evaluated the existing OnBeforeCheckBankAcc event as a potential alternative. However, this event fires before the entire CheckBankAcc procedure runs, meaning it bypasses all validations at once — including ones we do want to keep. Our need is more granular: we want to suppress only specific validations (the Open check or the Statement No. check) independently, depending on the scenario, while preserving the rest of the procedure's behavior.

There are no other existing events or extensibility points in CheckBankAcc that allow this level of control. We also considered using a TryFunction wrapper, but this approach silently swallows all errors without discriminating between them, which is not safe or maintainable. Duplicating the standard logic in a custom codeunit was evaluated but rejected as it creates a maintenance liability with every BC update.

Performance Considerations

Both events would only be raised inside CheckBankAcc, which is called once per Bank Account Ledger Entry being processed. This procedure is not invoked in loops over large datasets, but rather in targeted, entry-level operations such as manual reconciliations, reversals, or controlled integrations. The overhead of raising these events is negligible, as they follow the standard IsHandled pattern — if no subscriber is registered, the check if IsHandled then exit adds a single boolean evaluation and exits immediately, with zero measurable impact on performance.

Data Sensitivity Review

The only parameter exposed in both events is BankAccountLedgerEntry, a record of table "Bank Account Ledger Entry" (271), and the IsHandled: Boolean control variable.

The Bank Account Ledger Entry table is already widely exposed in existing standard BC events (e.g. OnAfterBankAccLedgEntryInsert, OnBeforeCloseBankAccountLedgerEntry), so its exposure does not introduce any new security surface. Extensions subscribing to these events must already have the standard permissions to read this table. No passwords, encryption keys, or sensitive personal data (GDPR-relevant) beyond what is already accessible through the record's standard permissions are involved. The events do not expose any write access to the record itself.

Multi-Extension Interaction

Both events use the IsHandled: Boolean pattern, which is consistent with standard BC extensibility conventions. The inherent risk with this pattern is that if multiple extensions subscribe and both set IsHandled := true, only the first subscriber to run effectively controls the behavior — the second one still executes its code but has no additional effect on the skipped validation.

This risk is acceptable and consistent with how BC handles all other IsHandled events across the platform. Partners are expected to coordinate their extensions if they target the same entry points, following the same conventions as any other BC integration event. Additionally, since these events are meant to skip a specific error, conflicting subscribers would at worst result in the validation being skipped — which is the intended outcome for any subscriber that sets IsHandled := true. There is no risk of data corruption or inconsistent state as a result of multiple subscribers.

MortegaITB avatar Apr 16 '26 12:04 MortegaITB

Hi @MortegaITB,

Thanks for submitting this extensibility request. To help us process it efficiently, please update the issue to include the required information.

📚 Extensibility Guidelines

Missing Information:

  • Alternatives Evaluated: Please describe which existing extensibility points or patterns you evaluated, including whether the existing OnBeforeCheckBankAcc event was considered, and why they do not satisfy your scenario.
  • Performance Considerations: Please add a short note about expected execution frequency and why the requested IsHandled events would not cause problematic overhead.
  • Data Sensitivity Review: Please confirm whether any sensitive or security-relevant data is involved and why exposing these event parameters would be safe.
  • Multi-Extension Interaction: Please describe any risk of conflicting subscribers if multiple extensions use these IsHandled events and how that risk is acceptable or mitigated.

Please update the issue with the missing details. We'll automatically re-analyze once updated.

AleksandricMarko avatar Apr 17 '26 10:04 AleksandricMarko

Hi @AleksandricMarko

I have already added the missing information.

Thanks.

MortegaITB avatar May 11 '26 12:05 MortegaITB

Hi @MortegaITB,

After analyzing the codebase, I found that an existing extensibility point is already present at the right procedure level: OnBeforeCheckBankAcc. Instead of adding two new publishers inside CheckBankAcc, the recommended approach is to enhance the existing event so it can control the two individual validations independently.

Recommended approach:

Extend the existing event with two additional Boolean var parameters, for example SkipOpenCheck and SkipStatementNoCheck, and use those flags to gate the two specific validations:

local procedure CheckBankAcc(BankAccountLedgerEntry: Record "Bank Account Ledger Entry")
var
    BankAccount: Record "Bank Account";
    CheckLedgerEntry: Record "Check Ledger Entry";
    IsHandled: Boolean;
    SkipOpenCheck: Boolean;
    SkipStatementNoCheck: Boolean;
begin
    IsHandled := false;
    OnBeforeCheckBankAcc(BankAccountLedgerEntry, IsHandled, SkipOpenCheck, SkipStatementNoCheck);
    if IsHandled then
        exit;

    BankAccount.Get(BankAccountLedgerEntry."Bank Account No.");
    JnlTemplName := BankAccountLedgerEntry."Journal Templ. Name";
    CheckPostingDate(BankAccountLedgerEntry."Posting Date", BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry."Entry No.");
    BankAccount.TestField(Blocked, false);
    if BankAccountLedgerEntry.Reversed then
        AlreadyReversedEntry(BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry."Entry No.");
    if (not SkipOpenCheck) and (not BankAccountLedgerEntry.Open) then
        Error(Text006, BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry."Entry No.");
    if (not SkipStatementNoCheck) and (BankAccountLedgerEntry."Statement No." <> '') then
        Error(Text007, BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry."Entry No.");
    CheckLedgerEntry.SetRange("Bank Account Ledger Entry No.", BankAccountLedgerEntry."Entry No.");
    if not CheckLedgerEntry.IsEmpty() then
        Error(Text003, BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry."Entry No.");

    OnAfterCheckBankAcc(BankAccount, BankAccountLedgerEntry);
end;

Please confirm if this alternative approach works for your scenario, or explain why the original approach with two separate new events is required.

AleksandricMarko avatar May 13 '26 10:05 AleksandricMarko

Hi @AleksandricMarko

Yes, this alternative approach works for my scenario and solves the requirement I had. I no longer need the original approach with the two separate new events.

Thank you for the change.

MortegaITB avatar May 18 '26 07:05 MortegaITB