- Microsoft Dynamics 365 Business Central Cookbook
- Michael Glue
- 313字
- 2021-06-24 13:24:08
How to do it...
- Open your AL project folder in Visual Studio Code.
- In Visual Studio Code's Explorer pane, right-click and create a new file named Customer Card Extension.al. In the Editor tab, add the following code, which does two things:
- It adds the Television Viewing Country field as the final field in the General section.
- It adds a new action button at the end of the Navigation group to show the television shows for the given customer:
pageextension 50100 CustomerCardExtension extends "Customer Card"
{
layout
{
addlast(General)
{
field("Television Viewing Country";
"Television Viewing Country")
{
ApplicationArea = All;
}
}
}
actions
{
addlast(Navigation)
{
action("Customer Television Shows")
{
ApplicationArea = All;
Image = ListPage;
RunObject = Page "Customer Television
Shows";
RunPageLink = "Customer No." = field
("No.");
}
}
}
}
Use the tpageext snippet to create a page extension object. You can also use the tpagefield and taction snippets to create new fields and actions.
- Now, it's time to test our new additions. Press F5 to build and publish your application. When your browser opens and you log in to your sandbox, perform the following steps:
- Use the
icon and search for customers to go on the Customer List.
- Select any customer to drill into the customer card.
- Use the
First, let's look for the new field that we added. Do you remember where we added it? You should be able to see it on the General tab:

Next, let's check the new action we added. On the customer card, select Navigate | Customer Television Shows. You may need to first select More options to see the Navigate link. This will open the Customer Television Shows page:

I told you it was easy!
Each Business Central application can contain only one page extension object per page. However, a page can be extended by multiple applications.