# Business Central AL Extension Skeleton Generator

> Source: https://netray.co/tools/business-central-al-extension-skeleton-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in publisher, prefix and ID range to get app.json, a table extension, a page extension, an event subscriber codeunit and a permission set.

## Category

developer

## Erp

Microsoft Dynamics 365 Business Central

## Audience

- AL developer
- BC partner developer
- NAV developer moving to AL

## Tool

**Kind:** template

**Output:** code

**Language:** text

**Fields:**

#### Publisher

**Key:** publisher

**Type:** text

**Default:** Contoso Partners

#### App name

**Key:** app_name

**Type:** text

**Default:** Customer Loyalty

#### Object prefix

**Key:** prefix

**Type:** text

**Default:** CLY

**Help:** Use your reserved AppSource or partner prefix.

#### ID range from

**Key:** id_from

**Type:** number

**Default:** 50100

#### ID range to

**Key:** id_to

**Type:** number

**Default:** 50149

#### New customer field

**Key:** field_name

**Type:** text

**Default:** Loyalty Tier

#### Field length

**Key:** field_len

**Type:** number

**Default:** 20

#### Application version

**Key:** platform

**Type:** text

**Default:** 26.0.0.0

**Blocks:**

#### app.json

**Body:** {
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "{{app_name}}",
  "publisher": "{{publisher}}",
  "version": "1.0.0.0",
  "brief": "{{app_name}} extension",
  "platform": "{{platform}}",
  "application": "{{platform}}",
  "idRanges": [
    { "from": {{id_from}}, "to": {{id_to}} }
  ],
  "runtime": "15.0",
  "target": "Cloud"
}

#### Table extension: Customer

**Body:** tableextension {{id_from}} "{{prefix}} Customer Ext" extends Customer
{
    fields
    {
        field({{id_from}}; "{{prefix}} {{field_name}}"; Code[{{field_len}}])
        {
            Caption = '{{field_name}}';
            DataClassification = CustomerContent;
        }
    }
}

#### Page extension: Customer Card

**Body:** pageextension {{id_from}} "{{prefix}} Customer Card Ext" extends "Customer Card"
{
    layout
    {
        addafter(Name)
        {
            field("{{prefix}} {{field_name}}"; Rec."{{prefix}} {{field_name}}")
            {
                ApplicationArea = All;
                ToolTip = 'Specifies the {{field_name}} of the customer.';
            }
        }
    }
}

#### Codeunit with event subscriber

**Body:** codeunit {{id_from}} "{{prefix}} Customer Events"
{
    [EventSubscriber(ObjectType::Table, Database::Customer, 'OnAfterInsertEvent', '', false, false)]
    local procedure SetDefaultOnInsert(var Rec: Record Customer; RunTrigger: Boolean)
    begin
        if Rec.IsTemporary() then
            exit;
        if Rec."{{prefix}} {{field_name}}" = '' then begin
            Rec."{{prefix}} {{field_name}}" := 'STANDARD';
            Rec.Modify();
        end;
    end;
}

#### Permission set

**Body:** permissionset {{id_from}} "{{prefix}} ALL"
{
    Assignable = true;
    Caption = '{{app_name}} all permissions';

    Permissions =
        tabledata Customer = RIMD,
        codeunit "{{prefix}} Customer Events" = X;
}

**Notes:** Each object here uses the same ID, which is allowed because IDs are unique per object type, but change them as you add objects so they stay inside your range. Generate a fresh GUID for app.json. Set the runtime value to match your target BC version in the AL Language extension. Add a ToolTip on every page field to satisfy AppSource validation. Verify syntax in VS Code with the AL Language extension before publishing.

## Content

**Intro:** Starting a Business Central extension means writing the same handful of files every time: app.json, a table extension, a page extension, an event subscriber and a permission set. This generator fills them with your publisher, prefix and ID range so you can paste them into a new AL project and begin with consistent naming.

**Sections:**

#### How to use the generator

**Body:** Enter your publisher, app name, an object prefix and the ID range assigned to you, plus the name and length of a new field on the Customer table. Copy each block into its own .al or app.json file in VS Code with the AL Language extension. Compile, then publish to a sandbox with F5. Adapt the objects to your design rather than keeping the sample customer field.

#### Why extensions replace base code changes

**Body:** In Business Central you do not change Microsoft's objects. A table extension adds fields to an existing table, a page extension adds controls to an existing page, and event subscribers react to published events instead of editing standard code. This keeps your changes separate, so Microsoft can update the base application without overwriting your work. It also makes your app installable per tenant and upgradeable.

**Bullets:**

- Table extension: add fields and keys
- Page extension: add or move controls
- Event subscriber: run code at defined points
- Permission set: grant access to your objects

#### Naming and ID conventions

**Body:** Prefix object and field names to avoid collisions with other apps, and keep IDs inside the range declared in app.json. AppSource apps get ranges from Microsoft, while per-tenant extensions commonly use 50000 to 99999. Use DataClassification on every field you add, and write captions and tooltips for end users. Your permission set should be small and explicit, not SUPER.

#### Common mistakes

**Body:** Using identical IDs across extension projects, forgetting permissions for new tables so users get errors in production, running code in OnInsert events on temporary records, and hard coding values that should be setup fields. Always test with a user who has only the roles they will have in real life.

**Cta:** If you are moving NAV customisations into AL extensions, Netray can help inventory the code and plan what to rebuild.

**Faq:**

#### What files does a minimal AL extension need?

**Answer:** At minimum an app.json manifest and one .al object file. A realistic extension also has a permission set, captions and tooltips, and a launch.json for connecting to a sandbox environment.

#### What ID range should I use?

**Answer:** Per-tenant extensions typically use 50000 to 99999. For AppSource or partner apps, request a range from Microsoft. Keep every object in the range declared in app.json.

#### Why is the field not visible after publishing?

**Answer:** Check that the page extension is part of the app, the field has ApplicationArea set, and personalization is not hiding it. Also confirm the app published without errors in the extension management page.

#### Can I edit standard Business Central code?

**Answer:** Not in SaaS or modern on-premises versions. You extend through table and page extensions, events and interfaces. Where no event exists, you can request one from Microsoft on GitHub.

## Search terms

business central al extension template, al table extension example, al page extension example, business central app.json example, al permission set example, business central event subscriber example, al extension skeleton, business central extension from scratch

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
