Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to Add a filter to...
Finance forum
Answered

How to Add a filter to display method in Form

editSubscribe (2) ShareShare
ReportReport
Posted on by 84
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.
  • Verified answer
    Ali AbdAlNasser Profile Picture
    Ali AbdAlNasser 84 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.
     
  • rajborad Profile Picture
    rajborad 170 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
    Mohamed Amine Mahmoudi 4,311 User Group Leader 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
    Waed Ayyad 2,526 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
    Ali AbdAlNasser 84 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
    Layan Jwei 3,079 Super User 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
    Martin Dráb 223,308 Super User 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
    Ali AbdAlNasser 84 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
    Martin Dráb 223,308 Super User 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?

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,375 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans