Limiting Field When Filter

Hi all,

Is it possible to limit certain fields only appear when the User filtering a report?

I want defined fields only appear when filtering the report; undefined fields will not appear when the User jot down the blank fields.

Please help.

Thanks, ZEN [:D]

Hi Zen,

as often in navision, there is no “direct” solution but there exists a possible work around… in the OnPreReport Section you can check what fields have been filtered with “GETFILTER”. Then you can either put together the report with several sections that you hide or show depending on these filtered fields, or you define a couple of generic text box fields, and assign the values in the OnAfterGetRecord dataitem for each filtered field that you want to show.

Hope I understood correctly your requirement…



The programming that needs to be done is actually hiding some fields that are not necessary. For example, the report is using item table and the defined fields for filtering the report are only “No.” and “Posting Date”, then, the rest of the fields (other than “No.” and “Posting Date”) will not be available for the User to enter/choose for filtering the data. Hope this explain.



I guess you don’t wnat the same item no printed 100 times on the repor, which makes sense.

Try this. In the onaftergetrecord trigger add this code:

ItemNoToPrint := “Item No.”
if itemnotoprint = LastItemNo then
ItemNotoprint := ‘’;
LastItemNo := “Item no.”

ItemNoToPrint and LastItemNo are Code20.
In the report replace “item no.” with ItemNoToPrint in the source expresion where Item No is normally printed.

Do the same with Posting date.


That’s not the one. I am sorry for the confusion

When I designed a report; I am normally set some fields in the ReqFilterFields property. I want to have only fields that are defined under ReqFilterFields property are available for report filtering; the rest of the fields that are not defined in ReqFilterFields property are not displayed/available for filtering.

Hope this explain better.



Sorry, no I just don’t see what you are trying to do then. Please explain with an example.

Ok fourth read, now I think I got it. If I understand, what you want is to prevent users from adding additional field tothe Request window for that table in a report. For example in Item ledger entry. If so then do this.

In the OnPreDataItem trigger add:
ItemLedgerEntry.copyfilters(“Item Ldeger Entry”);
ItemLdegerEntry.Setrange(“Item no.”);
ItemLdegerEntry.Setrange(“Posting Date”);
if ItemLdegerEntry.getfilters <> ‘’ then
error(‘It is not permitted to add additional filters to this report.’);

Hi Zen…

that explanation makes sense… you could also “hide” the normal Item dataitem filter tab (define a default key and don’t set any fields in the ReqFilterFields Option) and add those 2 allowed filters as new fields on the option tab, and then you add those filters with code in the dataitem, OnPreDataitem trigger. Like this users might not get confused when applying additional filters that won’t actually be applied.


David & Nils,

This is cool!

Where is the right trigger to place the key for sorting the report?



OnPreDataItem Put it just below the code I suggested above.

Thank you David & Nils; my problem is solved. [Y]