Gather user data using the AL data type FilterPageBuilder

Share This Post

99% of the time I use the same coding patterns, and same commands, same data types … but once in a while you find something new and wonder. Hmmm, if Microsoft developed it, and use it in Base App, it might prove useful.

That brings me to the other day, when I’ve got a ticket related to Dimension Corrections. Then, by looking at the Base App code I stumbled upon a Data Type that I couldn’t recall using.

Meet FilterPageBuilder data type. It is used by the Add By Filter action.

In the documentation I found this:

FilterPageBuilder : “Stores filter configurations for a filter page. A filter page is a dynamic page type that contains one or more filter controls that enables users to set filters on fields of the underlying tables.”

Take, for example, this use case:

We are on Item Card, and we launch Item Availability By Location action.

We see low levels of inventory for some items /locations.

Wouldn’t be cool if we could create a Purchase Order, for that item, for a specific vendor (if Vendor No.” on item card does not work), and desired Quantity, from that page?

pageextension 50111 "SVItems by Location Matrix" extends "Items by Location Matrix"
{
    actions
    {
        addafter("&Item Availability by")
        {
            action(PurchaseItemByLocation)
            {
                ...
                begin
                    title := 'Choose Location';
                    location.Reset();
                    FilterLocationPageBuilder.AddRecord(title, location);
                    if FilterLocationPageBuilder.RunModal() then begin
                        location.SetView(FilterLocationPageBuilder.GetView(title));

                        if location.FindFirst() then
                            LocationCode := location.Code;
                       ....
                        

I’m using 2 FilterPageBuilder variables to collect the location and the quantity desired from user, the item is known since the underlying page is based on Item record. With these ingredients known, we can start cooking a purchase order and post it.

If you want to watch how I’ve done it, step by step, here is the video:

Thanks for watching and subscribing!

Share This Post

Related Articles

Leave a Reply

Recent Posts

Get Notified About New Posts

Categories

Discover more from Business Central Musings

Subscribe now to keep reading and get access to the full archive.

Continue reading