Logotipo de Bc Attachments Generator

Bc Attachments Generator

Comunidad
fernandoartalf
bc-attachments-generator

Implements standard document attachments, links, and notes on custom Business Central tables. Creates setup fields for visibility control, extends Attachment Document Type enum, generates event subscribers (OnAfterGetRecRefFail, OnAfterOpenForRecRef, OnAfterInitFieldsFromRecRef) in attachment management codeunit, adds table lifecycle triggers for orphan prevention on delete/rename, and extends card and list pages with the modern Doc. Attachment List Factbox. Handles SubPageLink configuration, control ID mapping for Links (Control1900383207) and Notes (Control1905767507) factboxes. Use when adding attachments to custom tables, implementing document management, enabling factboxes for documents, creating attachment integration on entities, adding links and notes to records, or preventing orphan attachment records on table operations.

Descripción general

Editorfernandoartalf
RepositorioAL-Copilot-Skills-Collection
Nombre de la habilidadbc-attachments-generator
Estrellas
28
Forks
8
Archivos incluidos
3
LicenciaMIT
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando la petición encaja con la habilidad.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Archivos incluidos: 3

    Scripts, plantillas y referencias que el modelo puede leer mientras trabaja. Los archivos son de solo lectura y nunca se ejecutan.

  • Código abierto

    Publicada por fernandoartalf en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Bc Attachments Generator en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-attachments-generator
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fernandoartalf/AL-Copilot-Skills-Collection.git /tmp/AL-Copilot-Skills-Collection
mkdir -p .claude/skills
cp -r /tmp/AL-Copilot-Skills-Collection/skills/bc-attachments-generator .claude/skills/bc-attachments-generator
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Bc Attachments Generator en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición encaja con la habilidad, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Bc Attachments Generator automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Bc Attachments Generator no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición que encaja con la habilidad, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

BC Attachments, Links & Notes Generator

Automates BC standard document attachment functionality on custom tables.

Overview

Generates complete attachment, link, and notes implementation for custom BC tables following Microsoft patterns. Creates 3 event subscribers, lifecycle triggers, modern factbox configuration, and setup controls.

Complete code templates available in: references/code-templates.md

Prerequisites

  • AL workspace with custom table
  • Setup table (or will create one)
  • Card and List pages for entity

Workflow

Step 1: Gather Information

Collect from user:

  • Entity name (e.g., "Statistical Account")
  • Table name and ID
  • Prefix (e.g., "BCS")
  • Primary key field (usually "No.")
  • Setup table name
  • Card and list page names

Step 2: Update Setup Table

Add 3 boolean fields to setup table:

  • "Enable Attachments" (InitValue = true)
  • "Enable Links" (InitValue = true)
  • "Enable Notes" (InitValue = true)

Location: src/Table/[Prefix][SetupName].Table.al

See code-templates.md for complete code.

Step 3: Update Setup Page

Add 3 fields to setup page layout in General group.

Location: src/Page/[Prefix][SetupName].Page.al

See code-templates.md for complete code.

Step 4: Create Enum Extension

Extend "Attachment Document Type" enum with custom value.

Location: src/Enum Extension/[Prefix]AttachmentDocType.EnumExt.al

al
enumextension [ID] "[Prefix] Attachment Doc Type" extends "Attachment Document Type"
{
  value([ID]; [Prefix][Entity])  // Remove spaces: "Statistical Account" → "BCSStatisticalAccount"
  {
    Caption = '[Entity]';
  }
}

Step 5: Create Attachment Management Codeunit

Create codeunit with 3 event subscribers + 5 procedures.

Location: src/Codeunit/[Prefix]AttachmentManagement.Codeunit.al

Event Subscribers:

  1. OnAfterGetRecRefFail - Handle record reference resolution for attachment factbox (Page::"Doc. Attachment List Factbox")
  2. OnAfterOpenForRecRef - Filter attachments when opening details (Page::"Document Attachment Details")
  3. OnAfterInitFieldsFromRecRef - Initialize attachment from record (Table::"Document Attachment")

Procedures:

  1. EntityEnabledAttachments(TableId) - Check if attachments enabled
  2. EntityEnabledLinks(TableId) - Check if links enabled
  3. EntityEnabledNotes(TableId) - Check if notes enabled
  4. DeleteRelatedDocumentAttachments(No) - Delete attachments on record delete
  5. CopyRelatedDocumentAttachments(OldNo, NewNo) - Copy attachments on rename

See code-templates.md for complete code.

Step 6: Add Table Lifecycle Triggers

Extend table with:

  • OnBeforeRename() - Copy attachments to new No., delete old ones
  • OnBeforeDelete() - Delete related attachments to prevent orphans

Location: Update existing table extension

See code-templates.md for complete code.

Step 7: Extend Card Page

Add factboxes section with:

  • Modern factbox: "Doc. Attachment List Factbox" (UpdatePropagation = Both)
  • Modify Links factbox: Control1900383207
  • Modify Notes factbox: Control1905767507

Note: The legacy "Document Attachment Factbox" is fully deprecated and must NOT be included.

Add OnOpenPage() trigger to set visibility variables.

Location: src/Page Extension/[Prefix][Entity]Card.PageExt.al

SubPageLink configuration:

al
SubPageLink = "Table ID" = const(Database::"[Base Table]"),
              "No." = field("No.");

See code-templates.md for complete code.

Control ID Note: If modify fails (e.g., "Control not found"), inspect base page to find actual IDs. They may vary between BC versions.

Step 8: Extend List Page

Repeat Step 7 for list page.

Location: src/Page Extension/[Prefix][Entity]List.PageExt.al

Step 9: Update Permissions

Add to permission set:

al
codeunit "[Prefix] Attachment Management" = X;

Step 10: Test

Critical tests:

  1. Upload attachment → verify appears in factbox
  2. Delete record → verify attachments deleted
  3. Rename record → verify attachments follow (copied to new No.)
  4. Navigate between records → verify factbox refreshes
  5. Toggle setup fields → verify factboxes hide/show

Troubleshooting

Factboxes Not Appearing

  • Check setup page: ensure "Enable Attachments/Links/Notes" checked
  • Verify OnOpenPage() trigger runs and sets variables
  • Confirm DATABASE::"[Table]" matches exactly (case-sensitive)

Attachments Not Filtering

  • Verify enum extension exists and builds first
  • Check SubPageLink includes correct "Table ID" and "No." field
  • Confirm OnAfterInitFieldsFromRecRef sets "Document Type" correctly

Orphan Attachments After Delete/Rename

  • Missing OnBeforeDelete trigger → Add and call DeleteRelatedDocumentAttachments()
  • Missing OnBeforeRename trigger → Add RenameAttachments() procedure

Links/Notes Factbox Visibility Not Working

  • Wrong control IDs → Inspect base page to find actual IDs
  • Common IDs: 1900383207 (Links), 1905767507 (Notes)
  • Base page may not have these factboxes

Factbox Not Refreshing on Navigation

  • Missing UpdatePropagation = Both on modern factbox
  • Add to "Doc. Attachment List Factbox" part

Multi-Entity Pattern

When adding attachments to multiple tables in one extension, use case statements in all event subscribers and procedures.

See code-templates.md for complete example.

Storage Best Practice

BC has database storage limits. Recommend:

  • Small files in BC attachments (< 1 MB)
  • Large files in SharePoint/OneDrive
  • Use Links factbox for SharePoint URLs

Quick Reference

Required Objects:

  • Setup fields (3 booleans)
  • Enum extension
  • Attachment management codeunit (3 event subscribers, 5 procedures)
  • Table triggers (OnBeforeDelete, OnBeforeRename)
  • Page factboxes (card and list)

Event Subscribers:

  • OnBeforeDrillDown (obsolete factbox)
  • OnAfterOpenForRecRef (details page)
  • OnAfterInitFieldsFromRecRef (initialization)

Factbox Control IDs:

  • Links: Control1900383207
  • Notes: Control1905767507
  • May vary by BC version

Real-world example: BC Scout Statistical Accounts

  1. Rename record → verify attachments follow (copied to new No.)
  2. Navigate between records → verify factbox refreshes
  3. Toggle setup fields → verify factboxes hide/show

Troubleshooting

Factboxes Not Appearing

  • Check setup page: ensure "Enable Attachments/Links/Notes" checked
  • Verify OnOpenPage() trigger runs and sets variables
  • Confirm DATABASE::"[Table]" matches exactly (case-sensitive)

Attachments Not Filtering

  • Verify enum extension exists and builds first
  • Check SubPageLink includes correct "Table ID" and "No." field
  • Confirm OnAfterInitFieldsFromRecRef sets "Document Type" correctly

Orphan Attachments After Delete/Rename

  • Missing OnBeforeDelete trigger → Add and call DeleteRelatedDocumentAttachments()
  • Missing OnBeforeRename trigger → Add RenameAttachments() procedure

Links/Notes Factbox Visibility Not Working

  • Wrong control IDs → Inspect base page to find actual IDs
  • Common IDs: 1900383207 (Links), 1905767507 (Notes)
  • Base page may not have these factboxes

Factbox Not Refreshing on Navigation

  • Missing UpdatePropagation = Both on modern factbox
  • Add to "Doc. Attachment List Factbox" part

Multi-Entity Pattern

When adding attachments to multiple tables in one extension, use case statements in all event subscribers and procedures.

See code-templates.md for complete example.

Storage Best Practice

BC has database storage limits. Recommend:

  • Small files in BC attachments (< 1 MB)
  • Large files in SharePoint/OneDrive
  • Use Links factbox for SharePoint URLs

Quick Reference

Required Objects:

  • Setup fields (3 booleans)
  • Enum extension
  • Attachment management codeunit (3 event subscribers, 5 procedures)
  • Table triggers (OnBeforeDelete, OnBeforeRename)
  • Page factboxes (card and list)

Event Subscribers:

  • OnBeforeDrillDown (obsolete factbox)
  • OnAfterOpenForRecRef (details page)
  • OnAfterInitFieldsFromRecRef (initialization)

Factbox Control IDs:

  • Links: Control1900383207
  • Notes: Control1905767507
  • May vary by BC version

Real-world example: BC Scout Statistical Accounts

Archivos incluidos

El modelo los lee según los necesita mientras la habilidad está cargada. Son archivos de solo lectura y nunca se ejecutan.

Preguntas frecuentes

¿Qué hace la habilidad de IA Bc Attachments Generator?

Implements standard document attachments, links, and notes on custom Business Central tables. Creates setup fields for visibility control, extends Attachment Document Type enum, generates event subscribers (OnAfterGetRecRefFail, OnAfterOpenForRecRef, OnAfterInitFieldsFromRecRef) in attachment management codeunit, adds table lifecycle triggers for orphan prevention on delete/rename, and extends card and list pages with the modern Doc. Attachment List Factbox. Handles SubPageLink configuration, control ID mapping for Links (Control1900383207) and Notes (Control1905767507) factboxes. Use when...

¿Por qué usar Bc Attachments Generator en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Bc Attachments Generator está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Bc Attachments Generator en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-attachments-generator. TypingMind lee el archivo SKILL.md de esa carpeta, empaqueta los archivos de la carpeta e instala el conjunto como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Bc Attachments Generator?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Bc Attachments Generator?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Bc Attachments Generator con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Bc Attachments Generator?

Sí. fernandoartalf la ha publicado en GitHub bajo la licencia MIT. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver el directorio

Crea ya tu propio espacio de trabajo con IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇