All posts

Adding a field to the Customer Card the right way

A table extension, an enum and a page extension, with the small decisions that keep your extension clean and upgrade-safe.

Published
Reading time
2 min

Adding a field to a standard page is usually the first thing anyone builds in AL. It’s also where habits form, good or bad. Here’s how I do it, and why.

The scenario

Sales wants to record when each customer prefers to be contacted: morning or afternoon. We need a new field on the Customer table, shown on the Customer Card.

We’ll create three objects:

Object ID Name
Enum 50100 ABC Contact Time
Table extension 50100 ABC Customer Ext
Page extension 50100 ABC Customer Card Ext
Tip

Prefix every object and field with your registered affix (here ABC). It prevents name clashes with Microsoft and other apps, and it’s required for AppSource.

Start with an enum, not an option

Option fields can’t be extended by other apps. An extensible enum can, so a partner or customer can add “Evening” later without touching your code.

enum 50100 "ABC Contact Time"
{
    Extensible = true;

    value(0; " ") { Caption = ' '; }
    value(1; Morning) { Caption = 'Morning'; }
    value(2; Afternoon) { Caption = 'Afternoon'; }
}

The blank first value matters: it’s the default for every existing customer, so nobody is silently marked as “Morning”.

Extend the table

tableextension 50100 "ABC Customer Ext" extends Customer
{
    fields
    {
        field(50100; "ABC Preferred Contact Time"; Enum "ABC Contact Time")
        {
            Caption = 'Preferred Contact Time';
            ToolTip = 'Specifies when the customer prefers to be contacted.';
            DataClassification = CustomerContent;
        }
    }
}

Two properties people often skip:

  • DataClassification tells Business Central how to treat the data for privacy requests. Contact preferences are customer content, not system metadata.
  • ToolTip on the table field is reused by every page that shows it, so you write it once.

Show it on the page

pageextension 50100 "ABC Customer Card Ext" extends "Customer Card"
{
    layout
    {
        addlast(General)
        {
            field("ABC Preferred Contact Time"; Rec."ABC Preferred Contact Time")
            {
                ApplicationArea = All;
            }
        }
    }
}

addlast(General) puts the field at the end of the General FastTab. Anchoring to a group rather than to a specific field (addafter(Name)) makes your extension less likely to break when Microsoft rearranges the page.

Warning

Don’t change a field’s ID or type after it’s been published to a customer’s environment. Schema changes like that need an upgrade path, and the publish will fail without one.

Recap

  1. Use an extensible enum instead of an option.
  2. Prefix everything with your affix.
  3. Set DataClassification and a tooltip on the table field.
  4. Anchor page changes to groups, not individual fields.

Small habits, but they add up to extensions that are easier to maintain and upgrade.