Share This Post

Microsoft D365 Business Central Page Extension Object

The Microsoft D365 Business Central 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 in to three sections. The first block consists of metadata for the overall page, the type of the page and the source table it is showing data from. The next section, the layout, explains the visual parts on the page. The last section specifies the actions that are published on the page.

Typing the shortcut tpage will generate the basic layout for a page object when using the AL Language extension in Visual Studio Code. When developing a solution for MS D365 Business Central, you will follow the code layout for a page as shown in the page example below:

page 50101 SimpleCustomerCard
{
PageType = Card;
SourceTable = Customer;
ContextSensitiveHelpPage = ‘my-feature’;

layout
{
area(content)
{
group(General)
{
field(“No.”; “No.”)
{
ApplicationArea = All;
CaptionML = ENU = ‘Hello’;

trigger OnValidate()
begin
if “No.” < ” then
Message(‘Number too small’)
end;
}

field(Name; Name)
{
ApplicationArea = All;
}
field(Address; Address)
{
ApplicationArea = All;
}
}
}
}
actions
{
area(Navigation)
{
action(NewAction)
{
ApplicationArea = All;
RunObject = codeunit “Document Totals”;
}
}
}
}

Microsoft D365 Business Central Page Extension Object Process

1. 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.

 Use Ctrl+Space to trigger IntelliSense and get assistance on code completion, parameter info, quick info, and member lists.

2. Page Extension Examples

In the following example, we use a table extension to extend the Customer table with a new field named ShoeSize of the datatype Integer.

Then we create a Microsoft D365 Business Central Page Extension Object that extends the Customer Card page object by adding a field control ShoeSize to the General group on the page.

The field control is included as the last control in the group using the addlast method. The example also displays how to attach a show only control to the page.

In the actions area, you can check what the syntax looks like for actions that execute triggers and actions that execute objects.

tableextension 50115 RetailWinterSportsStore extends Customer
{
fields
{
field(50116;ShoeSize;Integer)
{
trigger OnValidate();
begin
if (rec.ShoeSize < 0) then
begin
message(‘Shoe size not valid: %1’, rec.ShoeSize);
end;
end;
}
}

procedure HasShoeSize() : Boolean;
begin
exit(ShoeSize <> 0);
end;

trigger OnBeforeInsert();
begin
if not HasShoeSize then
ShoeSize := Random(42);
end;
}

pageextension 50110 CustomerCardExtension extends “Customer Card”
{
layout
{
addlast(General)
{
// control with underlying datasource
field(“Shoe Size”; ShoeSize)
{
ApplicationArea = All;
Caption = ‘ShoeSize’;

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

// display-only control (without underlying datasource)
field(ShoesInStock; 10)
{
ApplicationArea = All;
Caption = ‘Shoes in stock’;

}
}

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;

// Run page to test how actions work
RunObject = page “Absence Registration”;

}
}
}
}
}

You can reference Report and XMLPort objects and utilize these objects in the RunObject property, as well as, publish variables of the types Report and XMLPort and call AL methods on them.

This Microsoft D365 Business Central 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;
}
}
}
}

Pages are the main way to display and organize visual data in Microsoft Dynamics 365 Business Central. They are the primary object that a user will connect with and have a distinct behavior based on the type that you have choosen.

Pages are designed independently of the device they are to be rendered on and in this way the similar page can be used again across the phone, tablet and web clients. For more information on Microsoft D365 Business Central Page Extension Object, please contact us.

Share This Post

Leave a Reply

avatar
  Subscribe  
Notify of
Skip to toolbar