Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Put a filter on data from a view

Posted on by Microsoft Employee

Hi Guys

Might be a silly question, but i will ask anyway. :-)

I am modifying the form SalesPriceActual such the history of a customers purchases can be viewed on a new tabpage. To grab the data i have created a view, picking up data from Custinvoicetrans, joining Custinvoicejour to get the header information.

A have a grid on the new tabpage, datasource= the view i created.

What I am desperately trying to achieve is to filter the view such it only shows invoicelines from the customer I am on on tab one (overview).

I have looked on the net, but have not been able to find anything covering my requirement. 

Any help and/or hints will be much appreciated.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 224,741 Super User on at
    RE: Put a filter on data from a view

    You didn't answer my question, but your code suggests that you use a kind of link (such as Delayed), therefore the right solution would be to add a dynalink.

    Please look at Adding a view as a secondary datasource on a form, where we discussed adding a link, and replace addLink() with addDynalink().

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Put a filter on data from a view

    *SOLVED*

    This line in method "enter" on the tabpage:

       Datasource_ds.filter( fieldnum(datasource,invoiceaccount),CusttableDS.AccountNum);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Put a filter on data from a view

    Hi Martin

    Thanks for answer.

    I am a complete autodidact (self-trained) developer. Any chance you could guide me in more details?

    How to set a link? Anything to put in the filter method?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Put a filter on data from a view

    Thanks for answer. The two tables CustInvoiceJour and CustInvoiceTrans is already in the list of datasources.

    When the second tabpage is activated, i need it to only show (filter) the invoices issued to the customer i am standing on in tab 1.

  • sohaibcheema Profile Picture
    sohaibcheema 46,590 User Group Leader on at
    RE: Put a filter on data from a view

    I think if @palle adds one more table CustInvoiceJour inside form, it can be achieved without making any relationships. Because CustInvoiceTrans  already has relationship to CustInvoiceJour. Further CustInvoiceJour has relationship with CustTable.

  • Martin Dráb Profile Picture
    Martin Dráb 224,741 Super User on at
    RE: Put a filter on data from a view

    Aha, you expect to filter automatically, but you don't have any relation. You have to explicitly add a link or dynalink.

    What kind of join or link do you between your datasources?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Put a filter on data from a view

    OK, I will try.

    A form with two tabpages.

    First show a list of all customers. (just first to last, no filter, no nothing)

    Second show all CustInvoiceTrans. The datasource is a View, joining CustInvoiceTrans and CustInvoiceJour on the Invoiceaccount field. Activating the tabpage shows all records from all customers.

    I want to ONLY show CustInvoicetrans records from the customer that was active when i clicked the second tabpage.

    What code am I to add where (what method)?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Put a filter on data from a view

    Hi Martin

    I will get back shortly.

  • Martin Dráb Profile Picture
    Martin Dráb 224,741 Super User on at
    RE: Put a filter on data from a view

    Can you explain your problem, please? In general, you can filter views in the same way as tables.

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,663 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,741 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans