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

Community site session details

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

filter on multiple fields in a statement

(0) ShareShare
ReportReport
Posted on by 117

Hello,

can someone explain me how to combine filters across multiple fields?

How do I filter for the following records in a query?
record 1: field A: value C, field B: value D
record 1: field A: value E, field B: value F
...

When I use SetFilter("Field A"; 'C | E') and SetFilter("Field B"; 'D | F'). I also get the record where field A has value E and field B has value D.

Thank you and best regards
Nico

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,105 Moderator on at
    RE: filter on multiple fields in a statement

    What your are using is an "or" filter so to me it looks like the system is behaving exactly as designed.

    What is the result you want to achieve with your filtering?

  • Suggested answer
    YUN ZHU Profile Picture
    95,307 Super User 2025 Season 2 on at
    RE: filter on multiple fields in a statement

    Hi, hope the following helps.

    Cross-column search (OR filters on multiple fields) ★FilterGroup(-1)

    https://yzhums.com/28943/

    Thanks.

    ZHU

  • GER_Nico Profile Picture
    117 on at
    RE: filter on multiple fields in a statement

    Sorry, I didn't explain my problem properly.

    I have a table whose primary key consists of two fields. This means that I can only uniquely select a record with a combination of the two fields. But I want to select multiple records at the same time, which means I have to specify multiple of these combinations as well.

    In my case it is about the "Job Task" table, which primary key is clustered by the fields "Job No." and "Job Task No.". I would now like to select job task 1000 from job 12345 and job task 1200 from job ABCD. But I don't know how to specify the filter in order to only get these two job tasks and not also the job task 1200 from job 12345 and the job task 1000 from job ABCD.

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: filter on multiple fields in a statement

    Hi,

    You can try two method below

    Try with

    Record.Get("Primary Key first field","Primary Key second field");

    or 

    Record.reset;

    Record.setrange("Primary Key first field",<Value>)

    Record.setrange("Primary Key SEcond field",<Value>)

    Record.findfirst;

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-get-find-and-next-methods

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/fieldref/fieldref-setrange-method

    Thanks.

  • GER_Nico Profile Picture
    117 on at
    RE: filter on multiple fields in a statement

    Using the two methods, I retrieve each record individually. Unfortunately that doesn't solve my problem.

    I am working in a report with a dataitem. I can't pass many individual records there, just a filtered list.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans