Bc Attachments Generator logo

Bc Attachments Generator

Community
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.

Overview

Publisherfernandoartalf
RepositoryAL-Copilot-Skills-Collection
Skill namebc-attachments-generator
Stars
28
Forks
8
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by fernandoartalf on GitHub. Read the source before you install it.

Installation

Install the Bc Attachments Generator AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-attachments-generator
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Bc Attachments Generator in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Bc Attachments Generator on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Bc Attachments Generator is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Bc Attachments Generator AI skill do?

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...

Why use Bc Attachments Generator on TypingMind?

Because you install it once and use it with any model. Bc Attachments Generator is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Bc Attachments Generator in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-attachments-generator. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Bc Attachments Generator?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Bc Attachments Generator?

As many as you like. As long as a model supports skills, you can use Bc Attachments Generator with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Bc Attachments Generator AI skill free?

Yes. It is published on GitHub by fernandoartalf under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇