Logo Bc Api Query Generator

Bc Api Query Generator

Cộng đồng
fernandoartalf
bc-api-query-generator

Generates API query objects for Business Central that expose data via OData/REST endpoints using the QueryType = API pattern. Creates queries with single or multiple dataitems (table joins), proper API properties, column mappings, aggregation methods (Sum, Count, Average, Min, Max), filters, DataItemLink joins (InnerJoin, LeftOuterJoin, CrossJoin), and DataItemTableFilter. Supports multi-version APIs, date filters, and dimension columns. Use when asked to create an API query, generate a query endpoint, build a read-only API from joined tables, expose aggregated data via API, create reporting queries, or implement OData query endpoints.

Tổng quan

Nhà phát hànhfernandoartalf
Kho mãAL-Copilot-Skills-Collection
Tên kỹ năngbc-api-query-generator
Sao
28
Bản fork
8
Tệp đi kèm
3
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được fernandoartalf công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Bc Api Query Generator trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-api-query-generator
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

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-api-query-generator .claude/skills/bc-api-query-generator
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Bc Api Query Generator trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Bc Api Query Generator ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Bc Api Query Generator với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Business Central API Query Generator

Generates production-ready AL API query objects following Microsoft's API standards. Handles single-table and multi-table join patterns, aggregation, filtering, and proper OData endpoint configuration.

Overview

API queries (QueryType = API) expose read-only data via OData endpoints. Unlike API pages, queries:

  • Support joining multiple tables via nested dataitems
  • Support aggregation methods (Sum, Count, Average, Min, Max)
  • Support filters exposed as OData query parameters
  • Are read-only — no INSERT, UPDATE, DELETE
  • Cannot be extended

This skill generates:

  • API query with proper metadata properties
  • Single or multi-dataitem layouts with join configuration
  • Column mappings with camelCase naming
  • Aggregation and filter elements
  • File placed following feature-based folder convention

Advanced patterns and join examples: references/query-examples.md

Prerequisites

  • AL workspace with established object ID range
  • Source table(s) identified with join relationships
  • Clear list of columns to expose
  • API publisher, group, and version defined

Quick Start

al
query [ID] "[Prefix] [Entity] API"
{
    QueryType = API;
    APIPublisher = '[publisher]';
    APIGroup = '[group]';
    APIVersion = 'v2.0';
    Caption = '[entityCaption]', Locked = true;
    EntityName = '[entityName]';         // camelCase, singular
    EntitySetName = '[entityNames]';     // camelCase, plural

    elements
    {
        dataitem([dataItemName]; "[Source Table]")
        {
            column([fieldAlias]; "[Field Name]")
            {
                Caption = '[Caption]', Locked = true;
            }
        }
    }
}

Endpoint URL: ../[publisher]/[group]/[version]/companies({id})/[entitySetName]

API Query Properties

PropertyGuideline
QueryTypeAlways API for web service queries
APIPublisherCompany/publisher identifier, lowercase, no spaces
APIGroupLogical group: sales, purchasing, inventory, finance, reporting
APIVersionUse 'v2.0' or list 'v1.0', 'v2.0' for multi-version support
CaptionUse camelCase entity name, always Locked = true
EntityNamecamelCase, singular (e.g., customerSale, itemLedgerEntry)
EntitySetNamecamelCase, plural (e.g., customerSales, itemLedgerEntries)

DataItem Pattern — Single Table

Use for simple read-only exposure of a single table:

al
query [ID] "[Prefix] [Entity] API"
{
    QueryType = API;
    APIPublisher = '[publisher]';
    APIGroup = '[group]';
    APIVersion = 'v2.0';
    Caption = '[entityCaption]', Locked = true;
    EntityName = '[entityName]';
    EntitySetName = '[entityNames]';

    elements
    {
        dataitem([dataItemName]; "[Source Table]")
        {
            // Primary key / identifier columns
            column([alias]; "[Key Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Business data columns
            column([alias]; "[Business Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Date columns
            column([alias]; "[Date Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Amount / numeric columns
            column([alias]; "[Amount Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Dimension columns (if applicable)
            column([alias]; "[Dimension Field]")
            {
                Caption = '[Caption]', Locked = true;
            }
        }
    }
}

DataItem Pattern — Multi-Table Join

Use for joining related tables. Nest dataitems to create SQL JOINs:

al
query [ID] "[Prefix] [Entity] API"
{
    QueryType = API;
    APIPublisher = '[publisher]';
    APIGroup = '[group]';
    APIVersion = 'v2.0';
    Caption = '[entityCaption]', Locked = true;
    EntityName = '[entityName]';
    EntitySetName = '[entityNames]';

    elements
    {
        dataitem([parentDataItem]; "[Parent Table]")
        {
            // Parent table columns
            column([alias]; "[Parent Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            dataitem([childDataItem]; "[Child Table]")
            {
                DataItemLink = "[Child FK Field]" = [parentDataItem]."[Parent PK Field]";
                SqlJoinType = InnerJoin;

                // Child table columns
                column([alias]; "[Child Field]")
                {
                    Caption = '[Caption]', Locked = true;
                }

                // Aggregation column example
                column([alias]; "[Amount Field]")
                {
                    Caption = '[Caption]', Locked = true;
                    Method = Sum;
                }

                // Filter element example
                filter([filterAlias]; "[Filter Field]")
                {
                    Caption = '[Caption]', Locked = true;
                }
            }
        }
    }
}

SqlJoinType Property

Sets the data item link type between data items to determine the records included in the resulting dataset. Always set on the lower (nested) data item. Works together with DataItemLink to combine records — except for CrossJoin, which requires DataItemLink to be blank.

al
SqlJoinType = InnerJoin;
Join TypeDescriptionWhen to Use
LeftOuterJoinReturns every record from the upper (parent) data item, even if no matching record exists in the lower data item. Non-matching lower fields return null/default values.Most common for API queries. Use when you need all parent records regardless of child matches (e.g., all customers even those with no ledger entries).
InnerJoinReturns only records where a match is found between linked fields in both data items. Records without matches in either table are excluded.Use when you only want records that exist in both tables (e.g., only items that have been sold).
RightOuterJoinReturns every record from the lower (child) data item, even if no matching record exists in the upper data item. Non-matching upper fields return null/default values.Use when the child table is the primary dataset and you want all child records even without parent matches. Less common in API queries.
FullOuterJoinReturns all records from both data items, including records that have no matching value in either table. Non-matching fields return null/default values on both sides.Use for complete datasets where no records should be excluded (e.g., reconciliation queries).
CrossJoinProduces a Cartesian product — every row from the upper data item combined with every row from the lower data item. DataItemLink must be blank.Rarely needed. Use for generating all possible combinations (e.g., item × location matrix). Can produce very large datasets — use with caution.

Remarks:

  • The SqlJoinType property is always set on the lower (nested) data item, never on the root data item.
  • For LeftOuterJoin, InnerJoin, RightOuterJoin, and FullOuterJoin, the DataItemLink property establishes an "equal to" (=) comparison between fields.
  • For CrossJoin, the DataItemLink property must be left blank — no field comparisons are made.
  • When no SqlJoinType is specified, the default is LeftOuterJoin.

Choosing the right join type:

LeftOuterJoin (most common for APIs):
  Parent: [A, B, C]    Child: [A, B]
  Result: [A+A, B+B, C+null]  ← All parents included

InnerJoin:
  Parent: [A, B, C]    Child: [A, B]
  Result: [A+A, B+B]          ← Only matches

RightOuterJoin:
  Parent: [A, B]       Child: [A, B, D]
  Result: [A+A, B+B, null+D]  ← All children included

FullOuterJoin:
  Parent: [A, B, C]    Child: [A, B, D]
  Result: [A+A, B+B, C+null, null+D]  ← All records from both

CrossJoin (no DataItemLink):
  Parent: [A, B]       Child: [X, Y]
  Result: [A+X, A+Y, B+X, B+Y]  ← Every combination

DataItemLink Syntax

al
DataItemLink = "[ChildField]" = [ParentDataItemName]."[ParentField]";
  • Links child dataitem to parent using foreign key relationship
  • Multiple links separated by commas:
    al
    DataItemLink = "Document Type" = [parentItem]."Document Type",
                   "Document No." = [parentItem]."No.";

DataItemTableFilter

Apply fixed filters to restrict data at the dataitem level:

al
dataitem([name]; "[Table]")
{
    DataItemTableFilter = "Document Type" = FILTER(Invoice | "Credit Memo");
    DataItemTableFilter = "Posting Date" = FILTER(<> 0D);
}

Aggregation Methods

Use the Method property on columns for aggregation:

MethodDescription
SumTotal of numeric values
CountNumber of records
AverageAverage of numeric values
MinMinimum value
MaxMaximum value
al
column(totalAmount; "Amount (LCY)")
{
    Caption = 'TotalAmount', Locked = true;
    Method = Sum;
}

Rule: When using aggregation methods, non-aggregated columns become implicit GROUP BY fields.

Filter Elements

Expose filters as OData query parameters:

al
filter(dateFilter; "Posting Date")
{
    Caption = 'DateFilter', Locked = true;
}
  • Filters appear as query parameters in the OData URL
  • Use for date ranges, document type filtering, and status filtering
  • Filter elements do not produce output columns

Column Naming Conventions

AL FieldColumn AliasCaptionPattern
"Entry No."entryNo'Entry No.' or Locked = truecamelCase alias
"Customer No."customerNumber'CustomerNumber', LockedDescriptive names
"Posting Date"postingDate'PostingDate', LockedRemove spaces
"Amount (LCY)"amountLCY'AmountLCY', LockedInclude qualifier
"Sales (LCY)"totalSalesAmount'TotalSalesAmount', LockedDescriptive for aggregation
"Global Dimension 1 Code"globalDimension1CodeStandard dimension naming

Rules:

  • Use camelCase for all column aliases
  • Set Caption with Locked = true for API queries to prevent translation issues
  • Use descriptive aliases for aggregated columns (e.g., totalSalesAmount instead of salesLCY)

API Query Design Workflow

  1. Define purpose — What data needs exposure? Who consumes it? What aggregations?
  2. Identify tables — Primary table and related tables for joins
  3. Plan joins — Define DataItemLink relationships and SqlJoinType
  4. Select columns — Pick fields to expose, decide on aggregations
  5. Add filters — Expose date ranges and key filtering parameters
  6. Allocate object ID — Query objects typically in dedicated range
  7. Implement query — Create .Query.al file following naming convention
  8. Test endpoint — Verify OData response structure and data

File Naming Convention

Follow the pattern: [Prefix][EntityName]API.Query.al

Examples:

  • BCSStatLedgerEntryAPI.Query.al
  • BCSCustomerSalesAPI.Query.al
  • BCSItemInventoryAPI.Query.al

Place in feature folder: src/[Feature]/Query/ or alongside related feature files.

Checklist

Before completing API query generation:

  • QueryType = API set
  • API properties defined (publisher, group, version, entity names)
  • Caption set with Locked = true
  • All dataitems have meaningful names
  • DataItemLink defined for multi-table joins
  • SqlJoinType specified for each nested dataitem
  • DataItemTableFilter applied where needed
  • Column aliases use camelCase
  • Column Captions with Locked = true
  • Aggregation Methods applied where needed
  • Filter elements added for date ranges and key parameters
  • File follows naming convention: [Prefix][Entity]API.Query.al

References

For complete examples:

External Resources

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Bc Api Query Generator làm được gì?

Generates API query objects for Business Central that expose data via OData/REST endpoints using the QueryType = API pattern. Creates queries with single or multiple dataitems (table joins), proper API properties, column mappings, aggregation methods (Sum, Count, Average, Min, Max), filters, DataItemLink joins (InnerJoin, LeftOuterJoin, CrossJoin), and DataItemTableFilter. Supports multi-version APIs, date filters, and dimension columns. Use when asked to create an API query, generate a query endpoint, build a read-only API from joined tables, expose aggregated data via API, create reportin...

Vì sao nên dùng Bc Api Query Generator trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Bc Api Query Generator là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Bc Api Query Generator trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-api-query-generator. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Bc Api Query Generator?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Bc Api Query Generator với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Bc Api Query Generator với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Bc Api Query Generator có miễn phí không?

Có. Kỹ năng này được fernandoartalf phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇