Logo di Skill Events

Skill Events

Community
javiarmesto
skill-events

AL event-driven architecture for Business Central. Use when creating EventSubscribers, IntegrationEvents, BusinessEvents, or implementing publisher/subscriber patterns in extensions.

Panoramica

Pubblicato dajaviarmesto
RepositoryALDC-AL-Development-Collection
Nome della skillskill-events
Stelle
115
Fork
37
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da javiarmesto su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Skill Events in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/javiarmesto/ALDC-AL-Development-Collection/tree/main/.claude/skills/skill-events
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/javiarmesto/ALDC-AL-Development-Collection.git /tmp/ALDC-AL-Development-Collection
mkdir -p .claude/skills
cp -r /tmp/ALDC-AL-Development-Collection/.claude/skills/skill-events .claude/skills/skill-events
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Skill Events in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Skill Events non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Skill Events non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Skill: AL Event-Driven Architecture

Purpose

Discover, design, and implement event-driven patterns in AL Business Central extensions: event discovery via Event Recorder, subscriber/publisher creation, IsHandled patterns, and extensibility design.

When to Load

This skill should be loaded when:

  • Extending standard BC functionality (posting, validation, master data changes)
  • Designing custom integration events for a new codeunit or extension
  • A subscriber is not firing and needs investigation
  • An architecture requires extensibility points for future consumers
  • Implementing document posting interventions, workflow triggers, or UI customizations

Core Patterns

Pattern 1: Event Discovery with Event Recorder

Before writing any subscriber, discover which events are raised during the business process:

1. Open the Event Recorder in VS Code  ← VS Code command (not an agent tool)
2. Start recording
3. Execute the business process in BC (e.g., post a sales order)
4. Stop recording
5. Analyze the event list — filter by object or keyword
6. Identify the OnBefore/OnAfter event closest to your extension point

Use al_search_objects and al_get_object_definition to inspect publisher signatures. Use al_find_references to see who else subscribes to the same event.

Pattern 2: Event Subscriber

al
// Subscriber codeunit — name with "Handler" suffix
codeunit 50100 "Sales Document Events Handler"
{
    // Attribute breakdown:
    //   ObjectType  — Table, Codeunit, Page, Report, etc.
    //   ObjectId    — Database::"Sales Header" or Codeunit::"Customer Management"
    //   EventName   — exact name of the publisher procedure (e.g., OnBeforeInsert)
    //   ElementName — '' for table/codeunit events; field name for page field triggers
    //   SkipOnMissingLicense  — false (recommended: always run)
    //   SkipOnMissingPermission — false (recommended: always run)

    [EventSubscriber(ObjectType::Table, Database::"Sales Header",
                     OnBeforeInsert, '', false, false)]
    local procedure OnBeforeInsertSalesHeader(
        var SalesHeader: Record "Sales Header";
        RunTrigger: Boolean)
    begin
        ValidateCustomFields(SalesHeader);
    end;
}

Subscriber rules:

  • Procedure MUST be local
  • Parameter signature MUST exactly match the publisher (name, type, order)
  • One subscriber per event per codeunit (keep handler codeunits focused)
  • Never use Commit inside a subscriber unless absolutely necessary

Pattern 3: Integration Event Publisher with IsHandled

The standard extensibility pattern: OnBefore allows interception, OnAfter allows reaction.

al
codeunit 50101 "Customer Management"
{
    procedure CreateCustomer(var Customer: Record Customer): Boolean
    var
        IsHandled: Boolean;
    begin
        // 1. Raise OnBefore — subscribers can validate, modify, or skip
        OnBeforeCreateCustomer(Customer, IsHandled);
        if IsHandled then
            exit(true);

        // 2. Default logic
        if not Customer.Insert(true) then
            exit(false);

        // 3. Raise OnAfter — subscribers can react (logging, integration, etc.)
        OnAfterCreateCustomer(Customer);
        exit(true);
    end;

    [IntegrationEvent(false, false)]
    local procedure OnBeforeCreateCustomer(
        var Customer: Record Customer;
        var IsHandled: Boolean)
    begin
        // Empty body — subscribers provide the implementation
        // IsHandled = true → skip default logic
    end;

    [IntegrationEvent(false, false)]
    local procedure OnAfterCreateCustomer(var Customer: Record Customer)
    begin
        // Empty body — subscribers react after creation
    end;
}

IntegrationEvent attribute:

  • IntegrationEvent(IncludeSender, GlobalVarAccess)
  • IncludeSender = false — recommended for clean API (no coupling to publisher internals)
  • GlobalVarAccess = false — recommended (prevent subscribers from accessing publisher global vars)

Pattern 4: Business Event

Business events are user-disablable — use for optional, non-critical functionality:

al
[BusinessEvent(IncludeSender)]
local procedure OnCustomerCreditLimitExceeded(
    Customer: Record Customer;
    RequestedAmount: Decimal)
begin
    // Subscribers may send notification, log, or block — user can disable
end;
AttributeCannot be disabledUse for
IntegrationEventCorrectCritical business logic, posting interventions
BusinessEventCan be disabled by userOptional features, external integrations, notifications

Pattern 5: Well-Designed Event Parameters

al
// ✅ Good — rich context, var where modification expected, IsHandled for OnBefore
[IntegrationEvent(false, false)]
local procedure OnBeforePostDocument(
    var DocumentHeader: Record "Sales Header";   // var — subscriber may modify
    var DocumentLines: Record "Sales Line";      // var — subscriber may modify
    PostingDate: Date;                           // value — read-only context
    var IsHandled: Boolean)                      // var — subscriber may skip default
begin
end;

// ✅ Good — results context for OnAfter
[IntegrationEvent(false, false)]
local procedure OnAfterPostDocument(
    DocumentHeader: Record "Sales Header";       // value — read-only (already posted)
    PostedDocumentNo: Code[20];                  // result reference
    PostingResult: Boolean)                      // success/failure
begin
end;

Parameter design rules:

  • var Record — when subscribers should be able to modify the record
  • Non-var Record — when record is read-only context
  • Always include var IsHandled: Boolean in OnBefore events
  • Include result/outcome parameters in OnAfter events
  • Use meaningful parameter names that describe business intent

Workflow

Step 1: Discover Events

  1. Open the Event Recorder in VS Code (a VS Code command, not an agent tool)
  2. Execute the target business process in BC
  3. Review recorded events — filter by relevant object
  4. Use al_get_object_definition to inspect publisher signatures
  5. Use al_find_references to check existing subscribers (avoid conflicts)

Step 2: Design Event Architecture

For subscribing to existing events:

  1. Identify the right OnBefore / OnAfter event from Step 1
  2. Match the parameter signature exactly
  3. Create a handler codeunit with naming: "{Domain} Events Handler"

For creating new integration events in your codeunit:

  1. Identify logical extension points in your business logic
  2. Add OnBefore event with IsHandled pattern before key operations
  3. Add OnAfter event after key operations with result context
  4. Follow naming: OnBefore{Action} / OnAfter{Action}
  5. Choose IntegrationEvent (critical) or BusinessEvent (optional)

Step 3: Implement

Use the AL: Insert Event Subscriber VS Code command (not an agent tool) to scaffold subscriber/publisher structures, then fill the body:

al
// Subscriber handler codeunit
codeunit 50102 "Customer Validation Handler"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Customer Management",
                     OnBeforeCreateCustomer, '', false, false)]
    local procedure ValidateOnBeforeCreate(
        var Customer: Record Customer;
        var IsHandled: Boolean)
    begin
        ValidateCustomerCreditLimit(Customer);

        if ShouldSkipDefaultProcessing(Customer) then
            IsHandled := true;
    end;
}

Step 4: Verify

  1. Build: al_build — check for compilation errors (signature mismatches)
  2. Set breakpoint inside subscriber
  3. Debug: al_debug
  4. Execute the business process — confirm subscriber fires
  5. If subscriber does NOT fire, check:
    • Signature mismatch (most common cause)
    • Wrong ObjectType / ObjectId
    • Extension not published/active
    • Another subscriber set IsHandled = true before yours
    • SkipOnMissingLicense / SkipOnMissingPermission attributes

Common Scenarios

ScenarioEvent SourcePattern
Validate before postingOnBeforePost* on Codeunit "Sales-Post"Subscriber + IsHandled
Add fields to sales orderOnAfterInsert on Table "Sales Header"Subscriber (set defaults)
External integration triggerOnAfterPostDocument (custom)Publisher in your codeunit
Custom approval workflowOnBeforeRelease*Subscriber + IsHandled to block
UI field validationPage trigger OnAfterValidate on fieldSubscriber with ElementName
Master data change auditOnAfterModify on Table "Customer"Subscriber (log changes)

References

Constraints

  • This skill covers event discovery, design, and implementation patterns — it does NOT duplicate the passive rules in al-events.instructions.md (auto-applied to all .al files)
  • Do NOT create publishers without an OnBefore + OnAfter pair at minimum
  • Do NOT use Commit inside event subscribers unless absolutely required
  • Do NOT set IsHandled = true without clear documentation of why default logic is skipped
  • Subscriber debugging (breakpoints, snapshots) → load skill-debug.md
  • Subscriber performance overhead analysis → load skill-performance.md

Domande frequenti

Cosa fa la skill IA Skill Events?

AL event-driven architecture for Business Central. Use when creating EventSubscribers, IntegrationEvents, BusinessEvents, or implementing publisher/subscriber patterns in extensions.

Perché usare Skill Events su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Skill Events è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Skill Events in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/javiarmesto/ALDC-AL-Development-Collection/tree/main/.claude/skills/skill-events. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Skill Events?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Skill Events?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Skill Events: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Skill Events è gratuita?

Sì. È pubblicata su GitHub da javiarmesto con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇