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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Filters not working on Form

(0) ShareShare
ReportReport
Posted on by 1,883

Dears,

I develop one Form with multiple data sources. I have data source called CustInvoiceTrans on my Form. I'm trying to filter the data with InvoiceDate(FromDate and ToDate). For that I use executeQuery() method with below logic and once filter values passed the button Clicked have following code. But My gird is not filtering. Please advice.

public void executeQuery() //on custinvoiceTran datasoucre
{
  QueryBuildRange qbr1;
qbr1 = SysQuery::findOrCreateRange(this.query().dataSourceTable(tableNum(CustInvoiceTrans)), fieldNum(CustInvoiceTrans, InvoiceDate));

    if (FromDateCtrl.dateValue() !=systemDateGet() && ToDateCtrl.dateValue() !=systemDateGet())

   {
    qbr1.value(SysQuery::range(FromDateCtrl.dateValue(),ToDateCtrl.dateValue()));

    }

    else

{

       qbr1.value(SysQuery::valueUnlimited());

}
 super();  
}

void clicked()

{
 super();
CustInvoiceTrans_1_DS.executeQuery();


}

Thanks 

Faqru

*This post is locked for comments

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

    Your code looks fine to me. Is CustInvoiceTrans a root data source, or is it joined to another one? Is the grid bound to CustInvoiceTrans?

  • Faqruddin Profile Picture
    1,883 on at

    CustInvoiceTrans not root data source. Its linked with SalesTable. The values in grid From SalesTable, CustInvoiceTrans etc..

    3755.form.jpg

  • Verified answer
    Martin Dráb Profile Picture
    238,127 Most Valuable Professional on at

    If they're joined, you should be working with executeQuery() of the root datasource, shouldn't you?

  • Faqruddin Profile Picture
    1,883 on at

    Thanks Martin. Now I can filter the grid. And I replace the && symbol in If condition. if (FromDateCtrl.dateValue() !=systemDateGet() || ToDateCtrl.dateValue() !=systemDateGet()).

  • Suggested answer
    startax Profile Picture
    1,845 on at

    Hi,

    Use qbr.value(strfmt(‘(FromDate<=%1)&& (ToDate>=%2)’,Date2StrXpp(d),Date2StrXpp(d)));

  • Martin Dráb Profile Picture
    238,127 Most Valuable Professional on at

    Dinkar, don't use this syntax unless absolutely necessary. It's difficult to read and write and compiler can't check your code inside the string; using SysQuery::range() is much better.

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

News and Announcements

Season of Giving Solutions is Here!

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

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#3
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans