The AL developer environment is evolving with frequent updates. To stay up to date on the latest information and announcements, follow us on the Dynamics NAV Team Blog.

Page Extension Object

The page extension object extends a Dynamics 365 Business Central page object and adds or overrides the functionality.

The structure of a page is hierarchical and breaks down into three sections. The first block contains metadata for the overall page; the type of the page and the source table it is showing data from. The next section; the layout, describes the visual parts on the page. The final section details the actions that are published on the page.

For more information about the Page and Page Extension objects, see Pages Overview.

Note

Extension objects can have a name with a maximum length of 30 characters.

Snippet support

Typing the shortcut tpageext will create the basic layout for a table object when using the AL Language extension in Visual Studio Code.

Page extension examples

The following page extension object extends the Customer Card page object by adding a field control ShoeSize to the General group on the page. The field control is added as the last control in the group using the addlast method. In the actions area, you can see what the syntax looks like for actions that execute triggers and actions that run objects.

pageextension 50110 CustomerCardExtension extends "Customer Card"
{
    layout
    {
        addlast(General)
        {
            field("Shoe Size"; ShoeSize)
            {
                ApplicationArea = All;
                Caption = 'ShoeSize';

                trigger OnValidate();
                begin
                    if ShoeSize < 10 then
                        Error('Feet too small');
                end;
            }
        }

        modify("Address 2")
        {
            Caption = 'New Address 2';
        }
    }

    actions
    {
        addlast(Creation)
        {
            group(MyActionGroup)
            {
                Action(MyAction1)
                {
                    ApplicationArea = All;
                    Caption = 'Hello!';

                    trigger OnAction();
                    begin
                        Message('My message');
                    end;
                }

                Action(MyAction2)
                {
                    ApplicationArea = All;
                    RunObject = codeunit "Activities Mgt.";
                }
            }
        }
    }

    var
        Msg: TextConst = 'Hello from my method';

    trigger OnOpenPage();
    begin
        Message(Msg);
    end;
}

You can reference Report and XMLPort objects and use these objects in the RunObject property, as well as, declare variables of the types Report and XMLPort and call AL methods on them. This page extension object extends the Customer List page object by adding two actions; the first action calls the Customer - List report, the second action calls the Export Contact xmlport.

pageextension 50114 AddCustomerReport extends "Customer List"
{
    actions
    {
        AddLast("&Customer")
        {
            action("Customer List Report")
            {
                trigger OnAction();
                var
                    rep : Report "Customer - List";
                begin
                    rep.Run;
                end;
            }

            action("Export Contact List")
            {
                trigger OnAction();
                var
                    xml : XmlPort "Export Contact";
                begin
                    xml.Run;
                end;
            }
        }
    }
}

Applies To

Pages

See Also

Page Object
Page and Page Extension Properties
Developing Extensions
AL Development Environment