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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Filter Table Using Field

(1) ShareShare
ReportReport
Posted on by 75

Hi folks, I would need to filter the table using a field, here is what i am doing: 

The field in the red box is the Production No., and i would want to filter the table below (Routing Line) using this field, so every time the user select a production no, the table below shows only the routing line with this particular Production No.  For some reason my code is not working as expected, please advised, thank you guys!

scrnli_5F00_4_5F00_30_5F00_2020_5F00_4_2D00_37_2D00_38-PM.png

page 50100 "Routing Tasks Filter"
{
    ApplicationArea = Service;
    Caption = 'Routing Tasks';
    InsertAllowed = false;
    PageType = Worksheet;
    SaveValues = true;
    SourceTable = "Prod. Order Routing Line";
    SourceTableView = SORTING(Type, "No.", Status);
    UsageCategory = Tasks;

    layout
    {
        area(Content)
        {
            group(General)
            {
                Caption = 'General';

                field(ProdNoFilter; ProdNoFilter)
                {
                    ApplicationArea = Service;
                    Caption = 'Production No.';

                    trigger OnLookup(var Text: Text): Boolean

                    begin

                        ProdOrderNo.Reset;
                        ProdOrderNo.Setrange(Status, Status::Released);
                        if PAGE.RunModal(0, ProdOrderNo) = ACTION::LookupOK then begin
                            Text := ProdOrderNo."No.";
                            SetOrderNoFilter;
                            exit(true);
                        end;
                    end;
                }

            }

            repeater(Control1)
            {
                Editable = false;
                ShowCaption = false;

                field("Prod. Order No."; "Prod. Order No.")
                {
                    Caption = 'Production Order';
                    ApplicationArea = Service;
                    ToolTip = 'Specifies the estimated date when service should start on this service item line.';
                }
                field("No."; "No.")
                {
                    ApplicationArea = Service;
                }
                field(Description; Description)
                {
                    ApplicationArea = Service;
                }
            }
        }
    }



    procedure SetOrderNoFilter()
    begin
        FilterGroup(2);
        SetRange("Production Order No. Filter");
        ProdNoFilter := GetFilter("Production Order No. Filter");
        FilterGroup(0);
    end;

    [Scope('Cloud')]
    procedure SetAllFilters()
    begin

        SetOrderNoFilter()

    end;

    var

        ProdOrderNo: Record "Production Order";
        ProdNoFilter: Text;
}
tableextension 50100 "Routing Line Filter" extends "Prod. Order Routing Line"
{
    fields
    {
        field(92; "Production Order No. Filter"; Code[20])
        {
            Caption = 'Production Order No. Filter';
            FieldClass = FlowFilter;
            TableRelation = "Production Order"."No.";
        }
    }

}
  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

  • Suggested answer
    Chameera Kavinda Profile Picture
    510 on at

    Hi Bigbigapple,

    Good day to you.

    Hi have gone through your code and identified few changes.

    First you do not need a new fiterfield from "Prod. Order Routing Line", you can directly filter from the filed "Prod. Order No.". Then use CurrPage.Update after you filter the record. I have done modifications in two places( onLookup function and SetOrderNoFilter function). I will paste the code here and you can find the changes where I have commented.

    Hope this will be help you. Cheers...

    page 50100 "Routing Tasks Filter"
    {
        ApplicationArea = Service;
        Caption = 'Routing Tasks';
        InsertAllowed = false;
        PageType = Worksheet;
        SaveValues = true;
        SourceTable = "Prod. Order Routing Line";
        SourceTableView = SORTING(Type, "No.", Status);
        UsageCategory = Tasks;

        layout
        {
            area(Content)
            {
                group(General)
                {
                    Caption = 'General';

                    field(ProdNoFilter; ProdNoFilter)
                    {
                        ApplicationArea = Service;
                        Caption = 'Production No.';

                        trigger OnLookup(var Text: Text): Boolean

                        begin

                            ProdOrderNo.Reset;
                            ProdOrderNo.Setrange(Status, Status::Released);
                            if PAGE.RunModal(0, ProdOrderNo) = ACTION::LookupOK then begin
                                ProdNoFilter := ProdOrderNo."No."; //modified
                                SetOrderNoFilter;
                                ///exit(true);  commented
                            end;
                        end;
                    }

                }

                repeater(Control1)
                {
                    Editable = false;
                    ShowCaption = false;

                    field("Prod. Order No."; "Prod. Order No.")
                    {
                        Caption = 'Production Order';
                        ApplicationArea = Service;
                        ToolTip = 'Specifies the estimated date when service should start on this service item line.';
                    }
                    field("No."; "No.")
                    {
                        ApplicationArea = Service;
                    }
                    field(Description; Description)
                    {
                        ApplicationArea = Service;
                    }
                }
            }
        }



        procedure SetOrderNoFilter()
        begin
            //FilterGroup(2);   //  commented
            //SetRange("Production Order No. Filter");      //  commented
            //ProdNoFilter := GetFilter("Production Order No. Filter"); //  commented
            SetRange("Prod. Order No.", ProdNoFilter);      //  Added
            CurrPage.Update();  //  Added
            //FilterGroup(0);       //  commented

        end;

        var

            ProdOrderNo: Record "Production Order";
            ProdNoFilter: Code[20];     //DataType Changed
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 676 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 483 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 310 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans