Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Problem with filter functionality

Posted on by Microsoft Employee

Hi all,
i have a problem with the filter functionality in AX (4.0). I wrote the following code:

Query                   qry;
QueryBuildDataSource    qbds;
QueryBuildRange         qbr;
;
super();
 
qry = MyTable_ds.queryRun().query();
qbds = SysQuery::findOrCreateDataSource(qry, tableNum(MyTable));
qbr = qbds.addRange(fieldnum(MyTable, My_Field));
qbr.value('!0');
 

wich is executed if a specific CheckBox is set. It works as excepted.

But if i enter a new filter value into My_Field, the "!0" filter criteria is copied to another (NOT A SPECIFIC!) column. And this only happens, if there are columns before My_field, which are currently out of scope (not in the visible range).

Is this a bug or am i missing somesthing?

Thanks in advance,
Frank

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Problem with filter functionality

    Ok.

    Thank you for your help :)

    Frank

  • Martin Dráb Profile Picture
    Martin Dráb 229,993 Most Valuable Professional on at
    Re: Problem with filter functionality

    Seriously, if the problem is in Filter by Grid, Microsoft is probably the only one who can help you. Check also if there is no hotfix for this problem.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Problem with filter functionality

    Hi,
    >So you add a range by button (Beware! Your code adds a new range every time, it doesn't update existing ranges.)
    You are right, i know, but this only was a "test" button.

    >if you overwrite the range value using the Filter by Grid feature, the original filter applies to another field, right?
    Yes

    >Could you show the query after if fails?

    SELECT *
    FROM MyTable1
       WHERE ((NOT (ColumnC = 0))) AND ((ColumnA = 1.5E1))
       JOIN * FROM MyTable2
       WHERE MyTable1.FK_XXX = MyTable2.PK_XXX AND ((Prov_LockStateBool = 0))

    --> ColumnA = 1.5E1: Overwritten filter criteria (i entered 15 into the filter)
    --> ((NOT (ColumnC = 0))): This is (why ever) the automatically added filter...

    Frank

  • Martin Dráb Profile Picture
    Martin Dráb 229,993 Most Valuable Professional on at
    Re: Problem with filter functionality

    So you add a range by button (Beware! Your code adds a new range every time, it doesn't update existing ranges.) and if you overwrite the range value using the Filter by Grid feature, the original filter applies to another field, right?

    Could you show the query after if fails?

    Anyway, if you believe there is a problem in Filter by Grid, you should ask Microsoft for support.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Problem with filter functionality

    Hi

    >'m not sure what ColumnA is. Is this describing the situation when you would expect (NOT (My_Field = 0))?
    the source in my first post results in the select-statement in my second post. I got this with your suggested qbds.toString() statement. columnA is filterd with "!0".
    columnA is a column of type "real", columnB is a column with an Enum Type.

    >Where do you enter the filter value?
    Everything is working correct - until i press Ctrl+G (activate Filter) AND overwrite the "!0"-filter criteria in the grid. Realy strange is, that this "problem" only came up, if there are columns BEFORE columnA (containing "!0"...) wich are not visible - if i move columnA to the left, so it is one of the first columns, the problem does not appear...

    >Is the value copied in the grid or only when applying filter?
    The value is copied if i change the filter manually - pressing Ctrl+G and then overwrite the "!0"-filter criteria...

    >It the code correct?
    I hope so :). The form contains 2 DataSources (inner join) and a Grid and the button with the source from my first post...

    I removed all other source to avoid other problems/sideffects.

    Frank

  • Martin Dráb Profile Picture
    Martin Dráb 229,993 Most Valuable Professional on at
    Re: Problem with filter functionality

    I'm not sure what ColumnA is. Is this describing the situation when you would expect (NOT (My_Field = 0))?

    You say: "But if i enter a new filter value into My_Field, the "!0" filter criteria is copied to another (NOT A SPECIFIC!) column. And this only happens, if there are columns before My_field, which are currently out of scope (not in the visible range)."

    Where do you enter the filter value?

    Using Advanced Filter/Sort? Is the value copied in the grid or only when applying filter?

    Or do you have your own form control for that and the range is added in code? It the code correct?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Problem with filter functionality

    The SQL query looks like this:

    SELECT * 
     FROM MyTable1 
     WHERE ((NOT (ColumnA = 0))) 
      JOIN * FROM MyTable2 
      WHERE MyTable1.FK_XXX = MyTable2.PK_XXX AND ((ColumnB = 0))

    Frank

  • Martin Dráb Profile Picture
    Martin Dráb 229,993 Most Valuable Professional on at
    Re: Problem with filter functionality

    How does the SQL query look like in the case described? You can get it by qbds.toString().

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans