![Microsoft Dynamics 365 Business Central Cookbook](https://wfqqreader-1252317822.image.myqcloud.com/cover/478/36698478/b_36698478.jpg)
上QQ阅读APP看书,第一时间看更新
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:
![](https://epubservercos.yuewen.com/0E4D6D/19470377408801506/epubprivate/OEBPS/Images/896de138-37ef-4f66-8ddc-aa113d0039d3.png?sign=1738832165-TLxyjkCVECCh2YQLVCIgiUynLQf4GnnO-0-5ea4e9835ebae6ff66ecfc7e2a024055)
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:
![](https://epubservercos.yuewen.com/0E4D6D/19470377408801506/epubprivate/OEBPS/Images/b8280046-34e5-4b14-8e31-90ce8cd75012.png?sign=1738832165-tX24jwnLnPWt3BFEHtwAxOGzjp8QMuu2-0-d81a374f957c364d235c766e0946d92e)
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.