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)

Problem with filter functionality

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

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

  • Community Member Profile Picture
    on at

    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
    237,795 Most Valuable Professional on at

    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
    on at

    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
    237,795 Most Valuable Professional on at

    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
    on at

    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
    237,795 Most Valuable Professional on at

    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
    on at

    Ok.

    Thank you for your help :)

    Frank

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