AgentStack
SKILL verified MIT Self-run

Binding Event Subscribers

skill-emgreppi-business-central-ai-skill-binding-event-subscribers · by emgreppi

Turns event subscribers on and off dynamically using BindSubscription() and UnbindSubscription() with EventSubscriberInstance = Manual for conditional event handling. Use when disabling subscribers during batch jobs, enabling page-scoped validation, implementing feature toggles via setup, turning off event handlers for performance, or controlling dynamic event execution at runtime.

No reviews yet
0 installs
3 views
0.0% view→install

Install

$ agentstack add skill-emgreppi-business-central-ai-skill-binding-event-subscribers

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Binding Event Subscribers? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Skill: AL Event Binding

Validation Gates

  1. After Step 1: Manual codeunit compiles, subscribers don't fire without binding
  2. After Step 2: BindSubscription activates subscriber, events fire correctly
  3. Final: UnbindSubscription deactivates, no events fire after unbind

Note: Default to StaticAutomatic. Use Manual only for conditional/performance scenarios. Binding is session-specific.

Procedure

Step 1: Create Manual Subscriber Codeunit

codeunit  "  Subscribers"
{
    EventSubscriberInstance = Manual;

    [EventSubscriber(ObjectType::Table, Database::, 'OnAfterValidateEvent', '', false, false)]
    local procedure OnValidate(var Rec: Record )
    begin
        // Your validation logic here
        if StrLen(Rec.)  must be at least 3 characters');
    end;
}

Step 2: Bind in Context (Page/Codeunit)

pageextension  "  Card Ext" extends ""
{
    var
        EntitySubscribers: Codeunit "  Subscribers";

    trigger OnOpenPage()
    begin
        BindSubscription(EntitySubscribers);
    end;

    trigger OnClosePage()
    begin
        UnbindSubscription(EntitySubscribers);
    end;
}

Common Patterns

Conditional via Setup

procedure ProcessDocument(var SourceRecord: Record )
var
    AdvancedValidation: Codeunit " Advanced Validation";
    Setup: Record " Setup";
begin
    if Setup.Get() and Setup."Enable Advanced Validation" then
        BindSubscription(AdvancedValidation);

    Codeunit.Run(Codeunit::, SourceRecord);
    // Auto-unbinds when procedure ends
end;

Batch Job Optimization

UI subscribers bound only in pages, not in job queue codeunits:

  • Page: OnOpenPageBindSubscription(UINotifications)
  • Job Queue: No binding → no UI overhead

Important Notes

Binding behavior:

  • Session-specific (Session A binding doesn't affect Session B)
  • Auto-dissolves when codeunit instance goes out of scope
  • Cannot call Bind/Unbind on StaticAutomatic codeunits (runtime error)

Stale metadata: Recompiling bound codeunit shows error "subscriber is stale" - only during development, not production.

⚠️ Do NOT use Manual for critical business logic that must never be missed.

External Documentation

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.