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 :
Finance | Project Operations, Human Resources, ...
Suggested answer

How can I filter multiple values on the same field in a execute query method?

(0) ShareShare
ReportReport
Posted on by 18
hello ,
 
can anyone help me out with this query that How can I filter multiple values on the same field in a execute query method and in form it should be shown as is one of in filter.
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,796 Most Valuable Professional on at
    How can I filter multiple values on the same field in a execute query method?
    You can simply add one range for each value. For example:
     
    FieldId fieldId = fieldNum(MyTable, MyField);
    QueryBuildDataSource qbds = this.queryBuildDataSource();
    qbds.addRange(fieldId).value(queryValue('a'));
    qbds.addRange(fieldId).value(queryValue('b'));
    qbds.addRange(fieldId).value(queryValue('c'));
    Don't forget to remove existing ranges, otherwise you'd keep adding more and more ranges in executeQuery() and you'd be getting wrong results.
  • Siddharth Muju Profile Picture
    18 on at
    How can I filter multiple values on the same field in a execute query method?
    hello martin,
     
    i have tried this but its not working.
     
  • Martin Dráb Profile Picture
    236,796 Most Valuable Professional on at
    How can I filter multiple values on the same field in a execute query method?
    I'm sorry, but I have no solution for "not working". Please describe the behavior, what you've found when you debugged it and show us your code.
  • Siddharth Muju Profile Picture
    18 on at
    How can I filter multiple values on the same field in a execute query method?
     qbds = this.query().dataSourceTable(tableNum(customtable));
     qbds.clearRanges();
     qbds.addRange(fieldNum(customtable,InventLocationId)).value('value1');
     qbds.addRange(fieldNum(customtable,InventLocationId)).value('value2');
     
    i have written this code before super.
  • Martin Dráb Profile Picture
    236,796 Most Valuable Professional on at
    How can I filter multiple values on the same field in a execute query method?
    Okay, the remaining part is describing the problem and telling us what you found when you debugged it, e.g. how the query string looks like.
     
    Assuming that your code is in executeQuery() of CustomTable data source, you can replace qbds = this.query().dataSourceTable(tableNum(CustomTable)) with mere qbds = this.queryBuildDataSource().
     
    Also, using queryValue() may be necessary even with text values, because it escapes some special characters.
  • Siddharth Muju Profile Picture
    18 on at
    How can I filter multiple values on the same field in a execute query method?
    {Query  object 2f967200: SELECT FIRSTFAST FORUPDATE * FROM customTable(customtabe) WHERE ((InventLocationId = N'value1') OR (InventLocationId = N'value2')) OUTER JOIN FORUPDATE Person, Person FROM HcmWorker(Ref_HcmWorker_customField) ON customtabe.customField= HcmWorker.RecId OUTER JOIN FORUPDATE Name, RecId FROM DirPerson(Ref_DirPerson_customField_DirPerson_FK) ON HcmWorker.Person = DirPerson.RecId}
    this query was generated.
  • Martin Dráb Profile Picture
    236,796 Most Valuable Professional on at
    How can I filter multiple values on the same field in a execute query method?
    As you see, the ranges are correct, therefore the code does work.
    Your problem lies somewhere else, but I can't help you with it, because the only information your gave me is that "it doesn't work". That could mean anything.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 765 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 743

#3
Sumit Singh Profile Picture

Sumit Singh 551

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans