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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Filtering using OR AX 2012

(0) ShareShare
ReportReport
Posted on by 282

Hi all,

Running AX2012 R3 CU8.

I would like to filter on a form based on two fields, and have it display a line when either of the two conditions are met rather than when both are met - it would appear that this feature cannot be done by the basic Ctrl+F3 query edit

Would I be able to go into my existing form and manually insert an SQL SELECT filter over the form's current datasources?

The two fields in question come from two separate datasources which are linked together by a join - if the above is impossible would I have to alter both of these datasources and if so where would I do this?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jasman Profile Picture
    1,413 on at

    Try typing in

    ((<tablename>.<fieldname> == <some criteria>) || (<tablename>.<someotherfieldname> == <some criteria>))

    in one of the filter fields of a given table in the Query edit form.

  • jasman Profile Picture
    1,413 on at

    More info:

    www.axaptapedia.com/Expressions_in_query_ranges

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at
  • Suggested answer
    5400 Profile Picture
    7,162 on at

    Is it inquiry form or user input or update UI. If it is inquiry UI, please create view and add to data source impose the querybuilddatasource to filter the data through addrange.

    If it is user input UI, please use queryBuildDataSource direct in display source executequery() /init() method as per your business scenario to filter the data.

    Please find the OR/AND all type condition with multiple tables which will be good example.

    \Classes\CustCreditLimit_SalesParmTable\initQueryOrigOrder

  • lukbel Profile Picture
    282 on at

    Hi Sohaib, this would be ideal for my purposes - however when I try and add the range in a test example, I get the following error:

    "Argument 'field' is incompatible with the required type"

    the following is my attempt:

    testRange = this.query().dataSourceName('SalesLine').addRange(fieldStr(SalesLine,testField));

  • Suggested answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    put fieldNum instaed of fieldStr

    testRange = this.query().dataSourceName('SalesLine').addRange(fieldNum(SalesLine,testField));

    In general you error message means expected data type is being mismatched

  • lukbel Profile Picture
    282 on at

    Hi,

    It was fieldNum when I first did it and I got that error - I changed it to fieldStr because the field in question was a string - is there something else I should be keeping in mind?

  • 5400 Profile Picture
    7,162 on at

    do you have mutiple data source in form. if yes please put data source number. as sohaib told with fieldNum

  • lukbel Profile Picture
    282 on at

    Hi Bhaksar,

    I do have multiple data sources - where would I find the datasource number? also how would that be formatted? Like the following?

    .addRange(fieldStr(<number>,SalesLine,<fieldname>));

  • 5400 Profile Picture
    7,162 on at

    QueryBuildDataSource    qbds;

    QueryBuildRange    qrg;

    qbds = this.query().dataSourceTable(tableNum(salesline));

    qrg = qbds.addRange(fieldNum(salesline, testField));

    or you can use

    this.query().dataSourceNo(saleslinedatasourcenumber in ur form).addRange(fieldNum(SalesLine,testField));

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans