Filtering a drop down list in Business Central

  • Filtering a drop down list in Business Central

    Posted by DSC Communities on October 4, 2022 at 11:05 am
    • Dana Kisor

      Member

      October 4, 2022 at 11:05 AM

      I’m working in Business Central 18.3 (On Prem) and having trouble filtering a drop down list (field) completely. This is the code I have that works:

      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  field(FilteredSSPARTField; Rec.SSPART)
      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  {
      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  ApplicationArea = Basic, Suite;
      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Caption = ‘SSPART(s)’;
      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  LookupPageID = “Shared Option List”;
      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  TableRelation = “Shared Option Lists”.“Option Description”
      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  where(“List ID” = filter(‘SSPart’));

      but it only filters on the List ID field. I want to filter on two fields: “List ID” and “Contract Price Bin”
      If I hard code the value I want for Contract Price Bin, it works without issue:

      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  where(“List ID” = filter(‘SSPart’), “Contract Price Bin” = filter(‘abc123’));
      But I don’t want to hard code the value, I want to use the value of a field on the page. The page is populated by a record and has a populated field called “Contract Price Bin”.
      But when I try to use that, I get an error:

      Any Ideas how to make this work dynamicallly?

      Thanks

      ——————————
      Dana Kisor
      Lead Programmer
      Government Acquisitions, Inc
      Cincinnati OH
      ——————————

    • Dana Kisor

      Member

      October 4, 2022 at 2:54 PM

      Found the solution, thanks to a friend. Turns out my syntax was wrong. Instead of using the FILTER, I needed to use FIELD.
      The corrected line of code looks like this.

      Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  where(“List ID” = filter(‘SSPart’), “Contract Price Bin” = field(“Contract Price Bin”));

      ——————————
      Dana Kisor
      Lead Programmer
      Government Acquisitions, Inc
      Cincinnati OH
      ——————————
      ——————————————-

    DSC Communities replied 3 years, 6 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Filtering a drop down list in Business Central’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!