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)

Applying filters when a button is clicked

(0) ShareShare
ReportReport
Posted on by 190

Hello everyone, 

I have created a Form A, in which I have some filters that are activated when ButtonA is clicked. 

In class declaration i have: 

QueryBuildDataSource qbds1, qbds2;
QueryBuildRange qbr1, qbr2;

In Form's DatasourceA init method:

qbds1 = this.query().dataSourceTable(tableNum(TableA));
qbds1.clearDynalinks();
range1 = qbds1 .addRange(fieldNum(TableA, FieldRange));
qbds2 = qbds1.addDataSource(tableNum(TableB));
qbds2.addLink(fieldNum(TableB, FieldName), fieldNum(TableA, FieldName));
range2 = qbds2.addRange(fieldNum(TableB, FieldRange));

In form's Datasource A, executeQuery method:

range1.value(Control1.valueStr());
range2.value(TableB_Control2.valueStr());

In clicked method of Button A I have:

TableA_ds.executeQuery();

The problem is that when i firstly open the form range2 is applied. How can i remove it ?  I want ranges to be applied only when ButtonA is clicked.

I have tried the followed in init method of DatasourceA:

qbds1 = this.query().dataSourceTable(tableNum(TableA));
qbds1.clearDynalinks();
range1 = qbds1 .addRange(fieldNum(TableA, FieldRange));
qbds2 = qbds1.addDataSource(tableNum(TableB));
qbds2.addLink(fieldNum(TableB, FieldName), fieldNum(Table1, FieldName));

qbds2.clearRange(fieldnum(TableB, FieldRange));
range2 = qbds2.addRange(fieldNum(TableB, FieldRange));

Can anyone help please?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Brandon Wiese Profile Picture
    17,788 on at

    Maybe only set your range1 and range2 value() in the button clicked event?

  • Verified answer
    Srini Ramidi Profile Picture
    2 on at

    Hello,

    I think the Datasource A, executeQuery method runs automatically when you open the form so you need to move "range2.value(TableB_Control2.valueStr()); " to your Button A clicked method.  Also you can add break points to all the methods and debug the code to see which method applies the filter.

    Best,

    Srini

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