Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to Add a filter to display method in Form

(1) ShareShare
ReportReport
Posted on by 394
Hello everyone, I hope you are all doing well.

I have a form that contains a grid that takes its data from a query, and I have a field of type display method that performs a simple operation. I want to add a filter factor that includes this field because I cannot filter the data in the display method naturally.

I tried some solutions like creating a View and adding a field linked to a Static method, but it didn't work correctly.

Thank you for listening to me.
  • Suggested answer
    Ali AbdAlNasser Profile Picture
    394 on at
    How to Add a filter to display method in Form
    Hello everyone, I wish you a good day.

    I solved my problem by adding a filtering field and putting the filtering condition in it. I followed the steps in this article with some modifications: ExecuteQuery Method In D365 Forms
     
    Regarding the modifications I have applied, I have only made a minor change. Here is my edited version:
    public void executeQuery()
    {
       QueryBuildDataSource  queryBuildDataSource;
       queryBuildDataSource = this.query().dataSourceTable(tablenum(CustInvoiceTrans));
       queryBuildDataSource.clearRanges();
       if(MyComboBox.selection() == 1)
           queryBuildDataSource.addRange(fieldnum(CustInvoiceTrans, InvoiceId)).value(strFmt('INV*'));
       else if(MyComboBox.selection() == 2)
           queryBuildDataSource.addRange(fieldnum(CustInvoiceTrans, InvoiceId)).value(strFmt('!INV*'));
    
       super();
    }
    The code here value(strFmt('INV*')) represents Like in SQL and value(strFmt('!INV*')) represents Not Like in SQL.
    I stored the values All, FG, and INV in the ComboBox and then performed the filtering process as mentioned above.
    Thank you to everyone who helped me, I am grateful for that.
     
  • Raj Borad Profile Picture
    607 on at
    How to Add a filter to display method in Form
    Hi,
     
    Here is a solution provided for the AX 2012. You can check.
     
    Thank you,
    Raj
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    17,604 Super User 2025 Season 1 on at
    How to Add a filter to display method in Form
    Hi @Ali,
     
    Yes, you can't filter on a display method.
    I think you can create a query based tables or add your tables to datasource of your form.
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Suggested answer
    Waed Ayyad Profile Picture
    7,909 Super User 2025 Season 1 on at
    How to Add a filter to display method in Form
    Hi,
     
    You can't filter the display method. Did you try to add the Items table to your Query? by adding the correct relationships or try to use temp table to fill the needed data at run time.
     
    You can check the following link it maybe helps you or the Temp table solution:
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
  • Ali AbdAlNasser Profile Picture
    394 on at
    How to Add a filter to display method in Form
    Hello everyone,

    I apologize if I have made any mistakes or if I have not explained my problem well.
    I will now clarify exactly what I want to do.

    What needs to be done:
    I have a Form containing a Grid that displays data from the tables CustInvoiceTrans, CustInvoiceJour, inventitemgroupitem, CustTable, DirpartyTable, and inventitemgroup. I have created a query and set up all the tables correctly as shown in the image:

    Now I have added this query to the Form as a data source, but there is a field that I need to perform a specific calculation on. I need to check the ItemID in the CustInvoiceTrans table. If it starts with a certain value, I give it a descriptive name; otherwise, it takes a generic name. I have adjusted this field by adding a Display Method, and I naturally added it to the Grid as shown:

    However, I later discovered that the Filter tool does not respond to data in this field, and I cannot filter it. So, I asked my question: How can I filter the Display Method?
    I hope this clarifies everything.
    Best regards.
  • Layan Jwei Profile Picture
    7,725 Super User 2025 Season 1 on at
    How to Add a filter to display method in Form
    Hi Ali,

    Display methods can't be filtered. If you need to filter on it then I think you need to convert it into an actual field.

    As for the view, can you show us what you did exactly?

    Thanks,
    Layan Jweihan
  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    How to Add a filter to display method in Form
    Moved from Dynamics 365 general forum.
     
    Unfortunately I can't give you a solution of it didn't work correctly, because it can mean anything. You'll need to give us a better description of the problem.
  • Ali AbdAlNasser Profile Picture
    394 on at
    How to Add a filter to display method in Form
    My question revolves around D365 F&O forms and X++
  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    How to Add a filter to display method in Form
    You're asking in the general D365 forum, but your question clearly is about a particular product. Which one? Is it F&O?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,274 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,939 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans