Bc Number Series Generator 标志

Bc Number Series Generator

社区
fernandoartalf
bc-number-series-generator

按照 BC 标准模式,为 Business Central 中的自定义表实现自动编号系列分配。创建包含编号系列字段的设置表、带有 AssistEdit 过程的表扩展、OnBeforeInsert/OnBeforeRename 触发器,以及集成 AssistEdit 的页面扩展。支持手动和自动分配编号,并支持关联的编号系列。适用于需要添加编号系列、实现自动编号、为自定义表添加编号系列、创建带编号系列的 No. 字段,或实现 BC 标准编号模式的场景。

Add to TypingMind

概览

发布者fernandoartalf
代码仓库AL-Copilot-Skills-Collection
技能名称bc-number-series-generator
星标数
28
复刻数
8
附带文件
4
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 4 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 fernandoartalf 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Bc Number Series Generator AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-number-series-generator
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

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-number-series-generator .claude/skills/bc-number-series-generator
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Bc Number Series Generator,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Bc Number Series Generator。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Bc Number Series Generator 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Business Central Number Series Generator

Implements automatic number series assignment on custom tables following Microsoft's standard patterns. Generates setup tables, table extensions with triggers, and UI integration for seamless number series management.

Quick Start

1. Setup Table Pattern

al
table [ID] "[Prefix] [Module] Setup"
{
    Caption = '[Module] Setup';
    DataClassification = ToBeClassified;
    DrillDownPageID = "[Prefix] [Module] Setup";
    LookupPageID = "[Prefix] [Module] Setup";
    
    fields
    {
        field(1; "Primary Key"; Code[10])
        {
            AllowInCustomizations = Never;
            Caption = 'Primary Key';
        }
        field(2; "[Entity] Nos."; Code[20])
        {
            Caption = '[Entity] Nos.';
            DataClassification = ToBeClassified;
            TableRelation = "No. Series";
        }
    }
    
    keys
    {
        key(PK; "Primary Key")
        {
            Clustered = true;
        }
    }
}

2. Table Extension with Number Series Logic

al
tableextension [ID] "[Prefix] [Entity]" extends "[Base Table]"
{
    fields
    {
        field([ID]; "[Prefix] No. Series"; Code[20])
        {
            Caption = 'No. Series';
            DataClassification = ToBeClassified;
            TableRelation = "No. Series";
        }
    }
    
    trigger OnBeforeInsert()
    begin
        if "No." = '' then begin
            [Prefix]Setup.Get();
            [Prefix]Setup.TestField("[Entity] Nos.");
            if NoSeries.AreRelated([Prefix]Setup."[Entity] Nos.", xRec."[Prefix] No. Series") then
                "[Prefix] No. Series" := xRec."[Prefix] No. Series"
            else
                "[Prefix] No. Series" := [Prefix]Setup."[Entity] Nos.";
            "No." := NoSeries.GetNextNo("[Prefix] No. Series");
        end;
    end;
    
    trigger OnBeforeRename()
    begin
        if "No." = '' then begin
            [Prefix]Setup.Get();
            [Prefix]Setup.TestField("[Entity] Nos.");
            if NoSeries.AreRelated([Prefix]Setup."[Entity] Nos.", Rec."[Prefix] No. Series") then
                "[Prefix] No. Series" := Rec."[Prefix] No. Series"
            else
                "[Prefix] No. Series" := [Prefix]Setup."[Entity] Nos.";
            "No." := NoSeries.GetNextNo("[Prefix] No. Series");
        end;
    end;
    
    procedure AssistEdit(): Boolean
    begin
        if not [Prefix]Setup.Get() then
            exit(false);
        if NoSeries.LookupRelatedNoSeries([Prefix]Setup."[Entity] Nos.", xRec."[Prefix] No. Series", "[Prefix] No. Series") then
            "No." := NoSeries.GetNextNo("[Prefix] No. Series");
    end;
    
    var
        [Prefix]Setup: Record "[Prefix] [Module] Setup";
        NoSeries: Codeunit "No. Series";
}

3. Page Extension with AssistEdit

al
pageextension [ID] "[Prefix] [Entity] Card" extends "[Base Card Page]"
{
    layout
    {
        modify("No.")
        {
            trigger OnAssistEdit()
            begin
                if Rec.AssistEdit() then
                    CurrPage.Update();
            end;
        }
    }
}

4. Setup Page Pattern

al
page [ID] "[Prefix] [Module] Setup"
{
    ApplicationArea = Basic, Suite;
    Caption = '[Module] Setup';
    PageType = Card;
    SourceTable = "[Prefix] [Module] Setup";
    DeleteAllowed = false;
    InsertAllowed = false;
    UsageCategory = Administration;
    
    layout
    {
        area(Content)
        {
            group("Number Series")
            {
                Caption = 'Number Series';
                field("[Entity] Nos."; Rec."[Entity] Nos.")
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the number series used for [Entity].';
                }
            }
        }
    }
    
    trigger OnOpenPage()
    begin
        Rec.Reset();
        if not Rec.Get() then begin
            Rec.Init();
            Rec.Insert();
        end;
    end;
}

Prerequisites

  • Custom table with a "No." field (primary key or main identifier)
  • Available object ID ranges for setup table, page, and extension objects
  • Understanding of module/feature structure
  • Prefix convention established (e.g., BCS, CUSTOM, etc.)

Implementation Workflow

  1. Create Setup Table — Single-record table with primary key + number series field(s)
  2. Create Setup Page — Card page with auto-initialization on OnOpenPage
  3. Create Table Extension — Add "No. Series" field + OnBeforeInsert/OnBeforeRename triggers + AssistEdit procedure
  4. Create Page Extension — Wire up AssistEdit trigger on "No." field
  5. Test Behavior — Verify automatic assignment, manual override, AssistEdit lookup, and related series handling

Number Series Patterns

Pattern 1: Simple Number Series (Single Entity)

Use Case: One entity type needs automatic numbering (e.g., Statistical Accounts)

Setup Table:

al
field(2; "Statistical Account Nos."; Code[20])
{
    Caption = 'Statistical Account Nos.';
    TableRelation = "No. Series";
}

Logic: Direct assignment from setup field to record.

Pattern 2: Multiple Number Series (Multiple Entity Types)

Use Case: Multiple related entities in same module (e.g., Sales Orders, Sales Quotes, Sales Invoices)

Setup Table:

al
field(2; "Order Nos."; Code[20])
{
    Caption = 'Order Nos.';
    TableRelation = "No. Series";
}
field(3; "Quote Nos."; Code[20])
{
    Caption = 'Quote Nos.';
    TableRelation = "No. Series";
}
field(4; "Invoice Nos."; Code[20])
{
    Caption = 'Invoice Nos.';
    TableRelation = "No. Series";
}

Logic: Use document type or entity discriminator to select appropriate series.

Pattern 3: Related Number Series

Use Case: Series variations (e.g., STAT for manual, STAT-AUTO for automatic)

Logic: Use NoSeries.AreRelated() to check if user-selected series is valid:

al
if NoSeries.AreRelated(Setup."Default Nos.", xRec."No. Series") then
    "No. Series" := xRec."No. Series"
else
    "No. Series" := Setup."Default Nos.";

Benefit: Allows users to select different series from the same family without losing automatic assignment.

Key NoSeries Codeunit Methods

MethodPurposeExample
GetNextNo(SeriesCode)Get next number from series"No." := NoSeries.GetNextNo("BCS No. Series");
AreRelated(Series1, Series2)Check if two series are relatedif NoSeries.AreRelated(Setup."Nos.", xRec."No. Series")
LookupRelatedNoSeries(DefaultSeries, OldSeries, NewSeries)AssistEdit lookup for related seriesNoSeries.LookupRelatedNoSeries(Setup."Nos.", xRec."No. Series", "No. Series")

Trigger Behavior

Object Type Distinction:

  • Table objects: Use OnInsert, OnRename, OnDelete triggers
  • Table extensions: Use OnBeforeInsert, OnBeforeRename, OnBeforeDelete triggers

Since number series are typically added to existing BC tables, table extensions are the standard approach using the "OnBefore" trigger variants.

OnBeforeInsert (Table Extensions) / OnInsert (Tables)

When: Before new record is inserted into the database
Purpose: Automatically assign the next number if "No." is blank
Pattern:

  1. Check if "No." = ''
  2. Get setup record and validate series field
  3. Check for related series (user may have changed)
  4. Assign next number from series

Usage:

  • OnBeforeInsert: Use in tableextension objects extending base tables
  • OnInsert: Use in table objects you create from scratch

OnBeforeRename (Table Extensions) / OnRename (Tables)

When: Before primary key is renamed (changing "No.")
Purpose: Handle renaming with automatic number assignment
Pattern: Same as OnBeforeInsert but uses Rec."No. Series" instead of xRec."No. Series"

Usage:

  • OnBeforeRename: Use in tableextension objects extending base tables
  • OnRename: Use in table objects you create from scratch

Note: OnBeforeRename/OnRename is less common but ensures consistency if users attempt to rename the key field.

AssistEdit Procedure

Purpose: Provides lookup (F6/DrillDown) on "No." field to select from related series

Implementation:

al
procedure AssistEdit(): Boolean
begin
    if not [Prefix]Setup.Get() then
        exit(false);
    if NoSeries.LookupRelatedNoSeries([Prefix]Setup."[Entity] Nos.", xRec."[Prefix] No. Series", "[Prefix] No. Series") then
        "No." := NoSeries.GetNextNo("[Prefix] No. Series");
end;

UI Integration:

al
modify("No.")
{
    trigger OnAssistEdit()
    begin
        if Rec.AssistEdit() then
            CurrPage.Update();
    end;
}

User Experience: Clicking DrillDown (F6) or AssistEdit button opens number series selection, filters to related series only.

Setup Page Initialization

Goal: Ensure setup record always exists

Pattern:

al
trigger OnOpenPage()
begin
    Rec.Reset();
    if not Rec.Get() then begin
        Rec.Init();
        Rec.Insert();
    end;
end;

Why: Setup tables are typically single-record tables. This pattern auto-creates the record on first access, avoiding "record not found" errors.

Checklist

Before completing number series implementation:

  • Setup table created with "Primary Key" and "[Entity] Nos." fields
  • Setup page created with auto-initialization trigger
  • Table extension adds "[Prefix] No. Series" field
  • OnBeforeInsert trigger implements automatic numbering
  • OnBeforeRename trigger handles renaming (optional but recommended)
  • AssistEdit procedure implemented in table extension
  • Page extension wires up OnAssistEdit trigger on "No." field
  • Tested automatic number assignment (leave "No." blank)
  • Tested manual number override (enter "No." manually)
  • Tested AssistEdit lookup (DrillDown on "No." field)
  • Tested related series handling (if using series families)
  • Setup page accessible via search (UsageCategory = Administration)

Common Variations

Variation 1: Conditional Numbering

Use Case: Only apply automatic numbering if certain conditions are met (e.g., document type, status)

Pattern:

al
trigger OnBeforeInsert()
begin
    if ("No." = '') and (ShouldAutoNumber()) then begin
        // Standard numbering logic
    end;
end;

local procedure ShouldAutoNumber(): Boolean
begin
    // Custom logic (e.g., check document type, feature flag, etc.)
    exit(true);
end;

Variation 2: Multiple Series per Entity

Use Case: Different series based on type/category (e.g., Internal Projects use PROJ-INT, External use PROJ-EXT)

Setup Table:

al
field(2; "Internal Project Nos."; Code[20]) { TableRelation = "No. Series"; }
field(3; "External Project Nos."; Code[20]) { TableRelation = "No. Series"; }

Logic:

al
trigger OnBeforeInsert()
begin
    if "No." = '' then begin
        Setup.Get();
        case "Project Type" of
            "Project Type"::Internal:
                begin
                    Setup.TestField("Internal Project Nos.");
                    "No. Series" := Setup."Internal Project Nos.";
                end;
            "Project Type"::External:
                begin
                    Setup.TestField("External Project Nos.");
                    "No. Series" := Setup."External Project Nos.";
                end;
        end;
        "No." := NoSeries.GetNextNo("No. Series");
    end;
end;

Variation 3: Header-Lines Pattern

Use Case: Lines inherit series context from header (e.g., Sales Order Lines reference header's series)

Header:

al
trigger OnBeforeInsert()
begin
    if "No." = '' then begin
        Setup.Get();
        Setup.TestField("Order Nos.");
        "No. Series" := Setup."Order Nos.";
        "No." := NoSeries.GetNextNo("No. Series");
    end;
end;

Lines: No numbering logic needed — lines reference header via foreign key.

References

For complete working examples:

External Resources

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Bc Number Series Generator AI 技能有什么作用?

按照 BC 标准模式,为 Business Central 中的自定义表实现自动编号系列分配。创建包含编号系列字段的设置表、带有 AssistEdit 过程的表扩展、OnBeforeInsert/OnBeforeRename 触发器,以及集成 AssistEdit 的页面扩展。支持手动和自动分配编号,并支持关联的编号系列。适用于需要添加编号系列、实现自动编号、为自定义表添加编号系列、创建带编号系列的 No. 字段,或实现 BC 标准编号模式的场景。

为什么在 TypingMind 中使用 Bc Number Series Generator?

因为您只需安装一次,就能搭配任何模型使用。Bc Number Series Generator 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Bc Number Series Generator?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-number-series-generator。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Bc Number Series Generator?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Bc Number Series Generator 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Bc Number Series Generator 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Bc Number Series Generator AI 技能免费吗?

是的。fernandoartalf 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇