web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Understanding ListPart Page in Business Central

Aman Kakkar Profile Picture Aman Kakkar 99

When working with pages in Business Central, you may already be familiar with List Pages (to show multiple records) and Card Pages (to show details of a single record). But what if you want to display a list of related records inside another page?

That’s where the ListPart Page comes in.

A ListPart Page is a special type of page that cannot stand alone. Instead, it is designed to be placed as a subpage within another page (usually a Card page). You’ve already seen this concept in action in standard Business Central:

  • Sales Lines inside the Sales Order Card.
  • Purchase Lines inside Purchase Order Card.

In this blog, we’ll learn how to use a ListPart page by adding the standard Customer Ledger Entries as a subform to our Customer Card Page.

Adding a Standard Subform (Customer Ledger Entries)

Scenario - Let's say I want to see all the Customer Ledger Entries that are for Customer No. 50000. And then for Customer No. 70000. And then for 12000. Either I can go to customer ledger entries and apply filter for 50000, then 70000, etc. Or I need to go to each Customer in the Customer List/Card, then click on Ledger Entries Action and then see Customer Ledger Entries. But both of them require too much navigation/filterings.

Solution - To solve this, let's create a Page in business central with 4-5 fields for now with PageType as "ListPart" and SourceTable as "Cust. Ledger Entry", and attach it in the Customer Card itself so that I need not to navigate anywhere, and I can see my Customer's Customer Ledger Entries in the Customer Card itself.

Code for creating ListPart Page - 
page 50002 "Customer Ledger Entry Subform"
{
    ApplicationArea = All;
    Caption = 'Customer Ledger Entry Subform';
    PageType = ListPart;
    SourceTable = "Cust. Ledger Entry";
    Editable = false;

    layout
    {
        area(Content)
        {
            repeater(General)
            {
                field("Customer No."; Rec."Customer No.")
                {
                }
                field("Customer Name"; Rec."Customer Name")
                {
                }
                field("Credit Amount (LCY)"; Rec."Credit Amount (LCY)")
                {
                }
                field("Debit Amount (LCY)"; Rec."Debit Amount (LCY)")
                {
                }
                field(Amount; Rec.Amount)
                {
                }
            }
        }
    }
}
NOTE: Do not add UsageCategory Property in your ListPart. It will make your subform to be visible in the search bar, which is not a Standard Approach.

Let's now go and attach it to the Customer Card Page as a Subform. 

pageextension 50002 "Customer Card Ext" extends "Customer Card"
{
    layout
    {
        addafter(General)
        {
            part("Cust. Ledger Entries"; "Customer Ledger Entry Subform")
            {
                ApplicationArea = All;
                SubPageLink = "Customer No." = field("No.");
            }
        }
    }
}
And that's it. After publishing, my Customer Card will have Cust. Ledger Entries Subform attached to it. 



NOTE: The most important point to learn here is the SubPageLink property.

SubPageLink = "Customer No." = field("No.");

Here you will see that "Customer No." of Subfrom Page is the key field that connects with our Customer's "No." field. This creates a link that allow us to show only those Customer Ledger Entries that are related to a particular Customer, without adding any filters or without navigating anywhere.

Now, you can create your own custom table and subform page as well, and attach it to the Customer' Card Page.

Hope you’ve learned how to extend your Card page by attaching ListPart pages directly in your Card Page.

Comments