Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Need to Filter lookup records in business central.

Posted on by 1,652

Hi All,

I have one Enum type of Field in the vendor card page, and I have one field with lookup of Vendor table in the Fixed Asset card page, I want to filter lookup records in the Fixed Asset page based on selected value on the Vendor card page.

I tried to set table Relation property on the table field, but it is not working for me.

>>On fixed asset card page:

field(60151; "Gas Company"; Text[100])
        {
            DataClassification = ToBeClassified;
            TableRelation = Vendor.Name where("Vendor Type" = filter(= 3));
        }
pastedimage1675757946177v1.png

Can anyone help in this?

Thank You.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Need to Filter lookup records in business central.

    Good news

  • Inkey Solutions Profile Picture
    Inkey Solutions 1,652 on at
    RE: Need to Filter lookup records in business central.

    Thank You Nitin Verma, this is work for me.

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: Need to Filter lookup records in business central.

    Hi

    actually your code looks correct to me if your intention is to filter the vendor table for vendors that have vendor type=3

    can you insert a screenshot of what you get?

    what are the options of the enum of your Vendor Type field which I guess is Custom?

    DAniele

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Need to Filter lookup records in business central.

    Hi,

    You can do like as per below, instead of Table Relation, as Table relation required only Primary key field, and you are putting here Name which is not a part of the Primary key field.

    field(60151; "Gas Company"; Text[100])
            {
                DataClassification = ToBeClassified;
                trigger OnLookup()
                var
                    Vendor: Record Vendor;
                begin
                    Vendor.SetRange("Vendor type",VendorType::YourOptionhere);
                    if page.RunModal(page::"Vendor List",Vendor)=  Action::LookupOK then
                      "Gas Company" := Vendor.Name;  
                end;
    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans