Hello, today I want to share how to use FilterPageBuilder Data Type to create advanced filters before opening the list page.

Project Overview
Basic concepts
FilterPageBuilder Data Type
Version: Available or changed with runtime version 1.0.
Stores filter configurations for a filter page. A filter page is a dynamic page type that contains one or more filter controls that enable users to set filters on fields of the underlying tables.
The following methods are available on instances of the FilterPageBuilder data type.
Method name | Description |
---|---|
AddField(Text, Any [, Text]) | Adds a table field to the filter control for a table on the filter page. |
AddField(Text, FieldRef [, Text]) | Adds a table field to the filter control for a table on the filter page. |
AddFieldNo(Text, Integer [, Text]) | Adds a table field to the filter control for a table on the filter page. |
AddRecord(Text, Record) | Adds a filter control for a table to a filter page. The table is specified by a record data type variable passed to the method. |
AddRecordRef(Text, RecordRef) | Adds a filter control for a table to a filter page. The table is specified by a RecordRef variable passed to the method. This creates a filter control on the filter page, where users can set filter table data. |
AddTable(Text, Integer) | Adds filter control for a table to a filter page. |
Count() | Gets the number of filter controls that are specified in the FilterPageBuilder object instance. |
GetView(Text [, Boolean]) | Gets the filter view (which defines the sort order, key, and filters) for the record in the specified filter control of a filter page. The view contains all fields in the filter control that have a default filter value. |
Name(Integer) | Gets the name of a table filter control that is included on a filter page based on an index number that is assigned to the filter control. |
PageCaption([Text]) | Gets or sets the FilterPageBuilder UI caption. Defaults to the resource text if not explicitly set. |
RunModal() | Builds and runs the filter page that includes the filter controls stored in the FilterPageBuilder object instance. |
SetView(Text, Text) | Sets the current filter view, which defines the sort order, key, and filters, for a record in a filter control on a filter page. The view contains all fields that have default filters but does not contain fields without filters. |
Code in Business Central
pageextension 60100 "Vendor List Ext" extends "Vendor List" | |
{ | |
actions | |
{ | |
addafter("Ledger E&ntries") | |
{ | |
action("VendorLedgerEntries") | |
{ | |
ApplicationArea = Suite; | |
Caption = 'Ledger E&ntries Filter'; | |
Image = VendorLedger; | |
ShortCutKey = 'Ctrl+F9'; | |
ToolTip = 'View the history of transactions that have been posted for the selected record.'; | |
trigger OnAction() | |
var | |
FilterPageBuilder: FilterPageBuilder; | |
VendLedgerEntry: Record "Vendor Ledger Entry"; | |
VendorLedgerEntries: Page "Vendor Ledger Entries"; | |
begin | |
//Adds a filter control for a table to a filter page. | |
//The table is specified by a record data type variable that is passed to the method. | |
FilterPageBuilder.AddRecord('Vend. Ledger Entry Table', VendLedgerEntry); | |
//Adds a table field to the filter control for a table on filter page. | |
FilterPageBuilder.Addfield('Vend. Ledger Entry Table', VendLedgerEntry."Vendor No."); | |
FilterPageBuilder.Addfield('Vend. Ledger Entry Table', VendLedgerEntry."Document Type"); | |
FilterPageBuilder.Addfield('Vend. Ledger Entry Table', VendLedgerEntry."Posting Date"); | |
FilterPageBuilder.Addfield('Vend. Ledger Entry Table', VendLedgerEntry."Document Date"); | |
FilterPageBuilder.Addfield('Vend. Ledger Entry Table', VendLedgerEntry."Amount"); | |
FilterPageBuilder.Addfield('Vend. Ledger Entry Table', VendLedgerEntry."Remaining Amount"); | |
//Sets the FilterPageBuilder UI caption. | |
FilterPageBuilder.PageCaption := 'Vendors Ledger Entries Filter Page'; | |
//Builds and runs the filter page that includes the filter controls that are stored in FilterPageBuilder object instance. | |
if FilterPageBuilder.RunModal() then begin | |
//Sets the current sort order, key, and filters on a table. | |
VendLedgerEntry.SetView(FilterPageBuilder.GetView('Vend. Ledger Entry Table')); | |
//Applies the table view on the current record as the table view for the page, report, or XmlPort. | |
VendorLedgerEntries.SetTableView(VendLedgerEntry); | |
VendorLedgerEntries.Run(); | |
end; | |
end; | |
} | |
} | |
addfirst(Category_Process) | |
{ | |
actionref(VendorLedgerEntries_Promoted; VendorLedgerEntries) | |
{ | |
} | |
} | |
} | |
} |
Tests
Conclusion
Thanks to FilterPageBuilder Data Type we can create quick filters before opening the List Page involved. Undoubtedly, it is a Data Type, which I think is perhaps little used but very useful and powerful, since, in addition to filtering the List Page before opening it, it leaves us with modifiable filters in a more simple way, saving the end user a couple of clicks.
Code on GitHub
All the code used in this post can be found at the following link:
I hope this has been helpful.