Understanding Objects in Business Central, Part 2: The Page

Title card reading "Understanding Objects, Part 2: The Page" with a wireframe of a page labeled Actions, Views, Layout, and Triggers, and The BC Dr. logo.

In part 1, we created a table, and now you want to view the data in it. You open Business Central, and search for Commission Tiers, but nothing comes up.

The table is real. The fields, the keys, and the rules from Part 1 are all there. But a table has no face. Until you build a page, no one can see the data in the user interface.

Data nobody can see isn’t a feature. It’s a secret.

This post gives the table a face.

About This Series

This is the second post in Understanding Objects, a series that walks through the building blocks of AL development one object at a time. Each post stands on its own, so start wherever you need to.

  1. Tables
  2. Pages (you are here)
  3. Reports
  4. Codeunits
  5. Queries
  6. XMLports
  7. Enums
  8. Permission Sets
  9. Interfaces
  10. Extension Objects

Every example follows Alexander Bikes, a fictitious bike manufacturer and retailer in Gainesville, Florida, as it builds a custom sales commission module. In Part 1, the company created its first table, ABK Commission Tier, which stores what a sale earns by product type and margin: a bike sold at a 20% margin or better earns 4%, and so on. A later post will walk through the complete project step by step.

A Page Is a Description, Not a Drawing

Developers coming from typical Windows IDEs expect to build a page the way they always have. They expect a designer surface, controls dragged into place, pixel positions, anchors, tab order, and a second layout for the phone.

AL pages have none of that.

A page is not a screen. It is a description of one.

You tell Business Central which table the page shows, which fields matter, how they group together, and what actions a person can take. The client decides how to draw it. Microsoft’s documentation puts it plainly: pages are designed independently of the device they are rendered on, so the same page is reused across phone, tablet, and web clients.

I sum it up this way: pages describe, the client draws. You give up control of the pixels. In return, one page works on every device without a second layout.

I’ll be honest: I’m not always a fan. The approach works, and it’s why a page written years ago still runs on a phone today. But there are times when a clearly defined appearance is an advantage. Sometimes you know exactly where a field should sit and what should stand beside it, and the page will not let you say so.

That’s the trade, not a free lunch. Knowing it up front saves a lot of fighting with the client later.

Diagram titled "One Page, Three Screens." One page object, described as the Commission Tier table, seven fields, and two actions, is drawn three ways by the client: on web, tablet, and phone. Caption: Pages describe, the client draws.

The Page Owns No Data

Here’s the idea that makes everything else in this post click. A page stores nothing. Every page that shows data names a SourceTable, and the page is only a way of looking at that table and working with it.

Remember the record variable from Part 1, the window that shows one row at a time? Every page gets two of them automatically.

  • Rec is the record the page is showing right now. It’s that same window with a person standing in front of it.
  • xRec is the record as it was before the latest change. You don’t write to it. You read the values its fields hold and compare them with Rec, to see what a value is now against what it was a moment ago.

You will work with Rec constantly and read from xRec occasionally, and you never need to declare either one.

That has a practical payoff. The table from Part 1 already knows a commission percentage sits between 0 and 100, an ending date cannot fall before a starting date, and a tier must be blocked before it can be deleted. The page does not repeat any of it. A person types a value, the table’s rules run, and the page simply shows the result.

Diagram titled "The Page Sits on the Table." The Page layer (what people see and do) sits above the Table layer (what is stored and what is true). Typed values pass down through OnValidate, and data returns to the page through Rec. Caption: The page owns no data.

Pick the Type Before You Write the Layout

The fixed menu from Part 1 has a second, smaller menu inside it. Every page declares a PageType, and the type tells the client what kind of experience to build. These are the ones you will meet most often, described the way Microsoft describes them:

Page TypeWhat It Is For
ListEntity overviews and navigation, and inline editing of simple entities
CardMaster, reference, and setup data management
DocumentTransaction and other document management, such as a sales order with its lines
WorksheetLine-based data entry tasks, such as journals
ListPlusStatistics, details, and related data management
CardPart / ListPartA page embedded in another page, such as in a FactBox
RoleCenterAn overview of business performance and the start page for a user profile
NavigatePageA multi-step dialog, also known as a wizard
StandardDialog / ConfirmationDialogRoutine dialogs and yes or no confirmations
APIWeb service endpoints. These pages cannot be shown in the user interface

That last row surprises people. An API page has no screen at all. It’s still a page, because a page is a description of how to reach a table, and a web service is just another client.

Diagram titled "Page Types by Job." One Record: Card, Document, ListPlus. Many Records: List, Worksheet. Parts: CardPart, ListPart, HeadlinePart. Dialogs: StandardDialog, ConfirmationDialog, NavigatePage. Special: RoleCenter, API. Card and List are marked "Built in This Post."

The Type Is a Promise to the Client

Because you describe and the client draws, the page type carries more weight than it first appears. It is the main thing the client knows about your intent, and each type comes with its own rules. Microsoft’s guidance is specific:

  • A Worksheet must contain a single repeater.
  • A ListPlus should not contain a repeater at all. It embeds a ListPart that holds one.
  • On a Document, the lines part should come right after the header sections, and the first ListPart gets the most room on screen.
  • A CardPart or ListPart cannot embed other pages.

A mismatched page type usually still compiles. It just doesn’t behave consistently. Use the wrong one, and users may experience unexpected performance: a layout that wastes space, a page that behaves differently from every other page of its kind, or one that works on the web but disappoints on a phone.

The guidance also moves. PromptDialog arrived for Copilot experiences, and UserControlHost and ConfigurationDialog followed. So keep up with what Microsoft says about page types, and reread the page types article when system updates come around. Trust me, it’s a few minutes that can save hours of troubleshooting later.

Alexander Bikes needs the classic pair. A List page shows every tier at a glance, and a Card page shows one tier in full.

Anatomy of a Page

Microsoft describes a page as hierarchical, and the order of the sections matters:

  1. Properties that say what kind of page this is and which table it shows
  2. Layout that describes what people see
  3. Actions that describe what people can do
  4. Views that offer saved ways to filter a list (list pages only)
  5. Code, including triggers, at the end

Here’s the list page for the commission tiers.

Diagram titled "Anatomy of a Page" for page 50100 "ABK Commission Tiers," with five sections: Properties (what kind of page, on which table), Layout (what people see), Actions (what people can do), Views (saved ways to filter the list), and Triggers and Code (display logic only).
page 50100 "ABK Commission Tiers"
{
    Caption = 'Commission Tiers';
    PageType = List;
    SourceTable = "ABK Commission Tier";
    CardPageId = "ABK Commission Tier Card";
    Editable = false;
    UsageCategory = Lists;
    ApplicationArea = All;

    layout
    {
        area(Content)
        {
            repeater(Tiers)
            {
                field("Item Category Code"; Rec."Item Category Code")
                {
                }
                field("Item Category Description"; Rec."Item Category Description")
                {
                }
                field("Minimum Margin %"; Rec."Minimum Margin %")
                {
                }
                field("Commission %"; Rec."Commission %")
                {
                    StyleExpr = TierStyle;
                }
                field("Starting Date"; Rec."Starting Date")
                {
                }
                field("Ending Date"; Rec."Ending Date")
                {
                }
                field(Blocked; Rec.Blocked)
                {
                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action(BlockTier)
            {
                Caption = 'Block Tier';
                ToolTip = 'Blocks the selected tier so it no longer applies to new sales.';

                trigger OnAction()
                begin
                    Rec.Validate(Blocked, true);
                    Rec.Modify(true);
                end;
            }
        }
        area(Navigation)
        {
            action(ItemCategories)
            {
                Caption = 'Item Categories';
                ToolTip = 'Opens the list of item categories that tiers can apply to.';
                RunObject = page "Item Categories";
            }
        }
        area(Promoted)
        {
            actionref(BlockTier_Promoted; BlockTier)
            {
            }
        }
    }

    views
    {
        view(ActiveTiers)
        {
            Caption = 'Active Tiers';
            Filters = where(Blocked = const(false));
        }
    }

    trigger OnAfterGetRecord()
    begin
        if Rec.Blocked then
            TierStyle := 'Subordinate'
        else
            if (Rec."Ending Date" <> 0D) and (Rec."Ending Date" < WorkDate()) then
                TierStyle := 'Attention'
            else
                TierStyle := 'Standard';
    end;

    var
        TierStyle: Text;
}

As with tables, you do not have to type the skeleton. With the AL Language extension installed in Visual Studio Code, typing tpage generates the basic layout.

Here’s what Business Central builds from that description.

The Commission Tiers list page in Business Central showing five commission tiers for accessories and bikes, each with a starting date of 11/1/2027, and the Block Tier action in the action bar.

Two things in that picture came from the table, not the page. The rows are sorted by product type and then by margin, because that is the primary key from Part 1. And every tier shows a starting date nobody typed. The table’s OnInsert trigger filled in the work date when each tier was created.

Now let’s walk through it section by section.

Properties: What Kind of Page, on Which Table

Microsoft’s guidance is that a new page needs at least two properties: PageType and SourceTable. The rest of the block here does specific jobs.

  • CardPageId names the card page that opens when someone opens a tier from the list.
  • Editable = false makes the list read-only, so changes happen on the card.
  • ApplicationArea = All means the page always appears in the user interface. Since Business Central 2022 release wave 2, controls on the page inherit this value, which is why the fields below do not repeat it.
  • UsageCategory = Lists is the one that answers the sales manager from the opening scene.

A page is not searchable just because it exists. Without a UsageCategory, a page does not show up in Tell Me, the search box at the top of Business Central. That was the developer’s Monday morning problem. One property fixes it.

Layout: Areas, Groups, and Repeaters

The layout section is a tree. At the top are areas. area(Content) holds the main body of the page, and area(FactBoxes) holds the side panel for related information.

Inside an area, two containers do most of the work:

  • A repeater shows many records as rows. It is the heart of every list page.
  • A group shows fields from one record together. On a card page, each group becomes a FastTab, the collapsible sections you see on every card in Business Central.

Inside those sit the fields. Each one reads field(Name; Rec."Field Name"): a name for the control, then the source it displays. Notice what is missing. There is no width, no position, no label text, no data type, no lookup button. The caption comes from the table. The lookup comes from the table’s TableRelation. The FlowField calculates itself.

Inherited does not mean locked, though. Set a Caption on the page field and it overrides the one from the table, for that page only. That is useful when a field needs a different label in a different context. Use it on purpose, because every override is one more place the wording can drift.

The page asks. The table answers.

Diagram titled "From Code to Screen." Lines connect AL code to a wireframe of the Commission Tiers list: area(Promoted) to the Block Tier button, area(Navigation) to Item Categories under Related, view(ActiveTiers) to the Active Tiers view, repeater(Tiers) to three Bikes rows, and field(...) to the Commission % column.

Actions: What People Can Do

Actions are the buttons and menu items on a page. Like the layout, they live in areas, and the area decides where the action appears: area(Processing) for tasks, area(Navigation) for related pages, area(Reporting) for reports, and area(Creation) for new documents.

The two actions here show the two common shapes.

Item Categories uses RunObject. It opens another page and needs no code at all.

Block Tier uses an OnAction trigger. Look closely at the two lines inside it. The action calls Validate() and Modify(true), the same calls from Part 1 that make code respect the table’s rules. An action is code, and code has to ask for the rules.

The third area, area(Promoted), is where you decide which actions deserve a spot at the front of the action bar. Since Business Central 2022 release wave 2, you promote an action with an actionref that points at it. The action is defined once and referenced where it should stand out.

Views: Saved Ways to Look at a List

Views apply to list pages. Each one is a named filter (and optionally a sort order and layout) that appears in the filter pane. The ActiveTiers view hides blocked tiers with one line: Filters = where(Blocked = const(false)).

Two details are worth knowing. The views section must come after layout and actions. And view filters apply to table fields, not page fields, so a view can filter on a field the page does not even show.

Triggers: Display Logic Only

Pages have their own triggers. These are the ones you will use most:

TriggerWhen It Runs
OnOpenPageAfter the page is initialized and run
OnAfterGetRecordAfter a record is retrieved from the table, before it is displayed
OnAfterGetCurrRecordAfter the current record is retrieved
OnNewRecordAfter a new record is initialized, before it is inserted
OnInsertRecordBefore a new record is inserted into the table

The list page uses OnAfterGetRecord to pick a style for each row: grey for blocked tiers, red for expired ones, standard for the rest. The StyleExpr property on the Commission % field reads that variable.

Here is the part that catches people.

OnAfterGetRecord does not run for the row you clicked. It runs for every row the page reads. On a list, that means it has already fired for each row the page loaded before anything appears on screen, and it is independent of whichever record is selected. OnAfterGetCurrRecord is the one that follows the selection.

That is not a quirk. It is a job description.

Use OnAfterGetRecord for anything every row needs, like a style or a calculated column. Use OnAfterGetCurrRecord for anything that depends on the selected record, like enabling an action.

Diagram titled "Two Triggers, Two Jobs." OnAfterGetRecord runs for each row the page reads, shown with a marker on all five rows. OnAfterGetCurrRecord runs for the selected row, shown with a marker on one row.

The Card: One Record in Full

The card page is shorter, because most of the thinking is already done.

page 50101 "ABK Commission Tier Card"
{
    Caption = 'Commission Tier';
    PageType = Card;
    SourceTable = "ABK Commission Tier";
    ApplicationArea = All;

    layout
    {
        area(Content)
        {
            group(General)
            {
                Caption = 'General';

                field("Item Category Code"; Rec."Item Category Code")
                {
                }
                field("Item Category Description"; Rec."Item Category Description")
                {
                }
                field("Minimum Margin %"; Rec."Minimum Margin %")
                {
                }
                field("Commission %"; Rec."Commission %")
                {
                }
            }
            group(Validity)
            {
                Caption = 'Validity';

                field("Starting Date"; Rec."Starting Date")
                {
                }
                field("Ending Date"; Rec."Ending Date")
                {
                }
                field(Blocked; Rec.Blocked)
                {
                }
            }
        }
    }
}

Two groups, so two FastTabs. No UsageCategory, because people reach the card through the list and it does not need its own search result. No code at all.

The Commission Tier card in Business Central, headed "BIKES · 20.00 · 11/1/2027," showing a bikes tier with a 20 percent minimum margin and a 4 percent commission rate on two FastTabs, General and Validity.

Look at the heading: BIKES · 20.00 · 11/1/2027. Nobody wrote that either. With no instruction from the page, the client builds the heading from the record’s primary key.

One detail connects the two pages. Once a list names a CardPageId, the New, Edit, and Delete actions on the list follow the card page’s settings, not the list’s. Control what people can do to a tier on the card, and the list falls in line.

Where the Rules Live

Now for the test. The card has no validation code. So what happens when someone types an ending date that falls before the starting date? This tier starts on 11/1/2027, so let’s give it an ending date of 10/31/2027.

The Commission Tier card showing a page error banner and the message "The ending date cannot be earlier than the starting date" after an ending date of 10/31/2027 is entered against a starting date of 11/1/2027.

The error from Part 1 appears, word for word, and the card reports “Not saved.” The page didn’t check anything. The table did, because a person typing on a page always runs the field’s OnValidate trigger. The bad date never reaches the database.

It’s tempting to put that kind of check in the page instead. The page is right there, and the trigger is easy to write. Resist the urge.

A rule in a page only runs for people using that page. Another page on the same table skips it. So does a codeunit, an import, and an API call.

A rule written in a page protects one screen. A rule written in a table protects the data.

Diagram titled "Where the Rule Lives." With the rule in the page, only the path from this page is guarded, while another page and code and APIs reach the ABK Commission Tier table unchecked: one door guarded. With the rule in the table, all three paths pass through it: every door guarded.

So the division of labor is simple. The table decides what’s true. The page decides what’s shown.

One Trip Back to the Table

There’s one thing the pages above are missing: tooltips, the short help text that appears when someone hovers over a field. The actions have them. The fields do not.

That is on purpose. Starting in Business Central 2024 release wave 1, you can define a tooltip on the table field, and any page that uses the field inherits it automatically. So the right home for them is the table from Part 1:

field(4; "Commission %"; Decimal)
{
    Caption = 'Commission %';
    ToolTip = 'Specifies the commission rate a sale earns when it reaches this tier.';
    DecimalPlaces = 0 : 2;
    MinValue = 0;
    MaxValue = 100;
}

Write it once, and the list, the card, and every page built later all say the same thing. Describe it once, in the place everything else borrows from.

What About Pages You Did Not Create?

Everything in this post describes pages you create. Real projects also need to change pages they did not create, such as adding a field to the Salesperson Card. You cannot open those and edit them. We will cover how to handle that when we come to extension objects in Part 10.

What’s Next

Alexander Bikes can now see its commission tiers, open one, block one, and trust that the rules hold no matter how the data arrives. What it cannot do yet is hand someone a piece of paper.

In Part 3, we move from the screen to the printed page: reports, the object that turns data into something you can send, sign, and file.

Until then, open Visual Studio Code, type tpage, and put a face on the table you built last time. Give it a list, a card, and one action.

Describe the page. Let the client draw it.

Illustration of David Rhue, smiling

About the author

David Rhue is The BC Dr., a Business Central consultant who helps organizations diagnose what's broken and get more from their ERP.

David’s book, The Book on BC, arrives October 12, 2027.

More about David

Similar Posts