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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Filter data on field change D365

(0) ShareShare
ReportReport
Posted on by 167

I want filter my data source of a grid as user changes a lookup field. I search and came to know about executeQuery method in AX2012 but could`t find how to achieve it in D365 form. Any help will be appreciated, Thanks. 

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Filter data on field change D365

    The forms work exactly the same way in AX2012 and D365FO. The biggest difference is that if you are enhancing a Microsoft (or ISV) form, you need to develop your logic as extensions.

    You can look at the standard forms to see how to implement this functionality. For example LedgerJournalTable form has a lookup that you can use to filter All/Not posted/Posted.

    On this specific form, the filtering logic happens in another class but usually you can put such code directly on your form.

    Your solution consists of three parts:

    1) Hook in the modified method of the field, to trigger your functionality

    2) Modify the form data source query according to user's selection in the field

    3) Execute the data source query

  • arkhan97 Profile Picture
    167 on at
    RE: Filter data on field change D365

    Thanks Nikolaos,

    I tried the solution and when I changed the value of required field my data source filtered correctly but when I further change the field original data source appeared again in the grid. Please have a look to rectify my mistake.

    info(strFmt("Message is %1", VendorBid.VendorId ));     // it verified that my function called on every change

       IDAPVendorBid_ds.query().dataSourceTable(tableNum(VendorBid)).addRange(fieldNum(VendorBid,VendorId)).value(VendorBid.VendorId);

    VendorBid_ds.executeQuery();

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Filter data on field change D365

    Your code adds a new range every time it's executed. So you add more and more OR statements every time.

    You can either call data source clearRanges() method, or use SysQuery::findOrCreateRange to replace the previous range with new one.

  • arkhan97 Profile Picture
    167 on at
    RE: Filter data on field change D365

    Thank you very much. One other thing if you can tell I want to update FormRealControl value after grid data is filtered.

    For this I get control by controlName function then use realValue function to update value but it is not being updated on form.

    Thanks again

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Filter data on field change D365

    That's how you set value in a form control. If it doesn't work as expected, please post a new question and share more information about your scenario (is it a field bound to a data source, is it on a grid, your code). Thanks!

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,177

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 860 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 593 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans