Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to pass multiple v...
Finance forum
Suggested answer

How to pass multiple values in an execute query to filter?

Posted on by 144
Hi,
I have a table 1 with a field emp id. and example it has 3 values. 001, 002, 003.

I have a fast tab, with table 2 which as all emp ids updated. 

I need to write a query in table 2, where it can filter only 3 values from table 1 i,e 001, 002, 003. 
 
For example: I need to filter as is one of values.
  • RSX Profile Picture
    RSX 144 on at
    How to pass multiple values in an execute query to filter?

    Hi Martin,

    Yes, I understand how to add ranges. The examples I provided—001, 002, 003—were merely illustrative.

    My main concern is that "Table 1" could contain any number of employee IDs. I want "Table 2" to filter out all the employee IDs present in "Table 1."

    Currently, if I Override an execute query in Table 2 like this:

    this.query().dataSourceTable(tableNum(table2)).addRange(fieldNum(table2, empid)).value(queryValue(Table1.Empid));

    it only filters out a single employee ID from Table 1, rather than all relevant employee IDs.

    Could you please advise on how to achieve the desired filtering?

    Thank you!

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 228,706 Most Valuable Professional on at
    How to pass multiple values in an execute query to filter?
    You talk about adding a writing a query in a table, but you likely mean adding ranges to a form query.
     
    If you know how to add a range for a single value, you're almost there. Just add two more ranges in the same way:
    QueryBuildDataSource myTableQbds = myTable_ds.queryBuildDataSource();
    
    myTableQbds.addRange(fieldNum(MyTable, MyField)).value(queryValue('001'));
    myTableQbds.addRange(fieldNum(MyTable, MyField)).value(queryValue('002'));
    myTableQbds.addRange(fieldNum(MyTable, MyField)).value(queryValue('003'));

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,572 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,706 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans