Nested data items and filtering

mabl4367mabl4367 Member Posts: 143
Hello everyone!

I have created a report to do some data updates on sales headers and sales lines.

The report obviusly has one data item for Sales Header and one indented/nested data item Sales Line that have data item link "Sales Header"."Document Type"="Sales Line"."Document Type" and "Sales Header"."Document No."="Sales Line"."Document No."

The unusual thing about this report is that I would like filters set on the indented Sales Line data item to also affect what sales headers are processed. For example: If the user sets a filter on the filed Quantity on the sales line data item, only sales headers where there is at least one sales line with the same document type, document no. and a value in the field Quantity that pass the filter set on the field, shold be processed.

Sales Header 1.
Document Type Documetn No.
Order 1

Sales Lines
Document Type Documetn No. Line No. Quantity
Order 1 10000 10
Order 1 20000 200

Sales Header 2
Document Type Documetn No.
Order 2

Sales Lines
Document Type Documetn No. Line No. Quantity
Order 2 10000 10
Order 2 20000 300

If I run the report with the above sales headers and saleslines in the database and set the filter "Quantity>200" in the Sales Line data item, only Sales Header 2 should be processed and Sales Header 1 should be skipped.

The problem for me with this is that the filters set by the user on the fields of the Sales header data item doesn't seam to take effekt until the execution get to the sales line OnPreDataItem trigger and then it's to late to add additional filters on the Sales Header data item.

Is there any way to get the filters set by the user on the data items before execution get to the OnPreDataItemTriggers?

I can not simply reverse the order of data items and have the sales header indented under sales line since I also want to be able to filter the sales lines on data that is located in the fields of their respective sales headers. Also i thing the preformence would suffer since there are a lot more sales lines then there are sales headers.


  • Options
    matttraxmatttrax Member Posts: 2,309
    You can create another Sales Line data item that the user will use to set the filters; perhaps it should be the first data item in the report. Once you get to the main data items you can copy those filters and use them to do the processing.
  • Options
    kinekine Member Posts: 12,562
    All depends on what do you mean with "processed". If you just do not want to display such a headers, use the OnlyIfDetails property on the header dataitem.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    mabl4367mabl4367 Member Posts: 143
    Rigth now I use Print only if detail but also don't want any data to be updated in the records that are not printed.

    I think Matttrax sugestion would work although I'm not sure how to present this data item in a way that makes the prupose of it obvius to the user. Maby it would be enough to set a good descriptiv caption on it.

    Thanks guys!
  • Options
    mabl4367mabl4367 Member Posts: 143
    Now that I started to implement Matttrax sugestions it dawned on me that I can simply copy both data items into dummy data items tat are only used to get the filters from the user. I can then remove the two original data items from the request form and copy the filters from the dummy items by code.
  • Options
    krikikriki Member, Moderator Posts: 9,098
    [Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!

Sign In or Register to comment.