I have a report and when I run it, it needs to display a default value in one of the fields on the first data item and the user may/may not change that. Does any one know how to program this? I tried using setfilter, setrange in Oninitreport, onprereport, onpredataitem etc but none works. Thanks
0
Comments
is there a reason you haven't used the dataitemtableview property of the dataitem to set the filter?
or perhaps use currreport.skip - if it's not a value that you want
what do you mean by display the value? are you looking for something like when you print an invoice and the inv# already appears in the report, but still allows you to use the other filters?
http://www.BiloBeauty.com
http://www.autismspeaks.org
Plant Group
Company
Item
Plant Group
--Company
----Item
Based on my understanding the request form is presented to the user after the oninitreport and before the onprereport. So something needs to be done, if any, on the onintreport to achieve what I am looking for.
Since it's not on the company dataitem perhaps you need a company.get; :-k
http://www.BiloBeauty.com
http://www.autismspeaks.org
1. This thread happens to be in the top Google search for this topic
2. This topic has not been sufficiently answered in any of the top search hits.
Issue:
User wants to run a report directly. Upon load, a field that pertains to a DataItem needs to be preset with a filter value. This filter value needs to display on the Request Form of the report.
Answer:
It is not possible to set filters on DataItems that will display in the Request Form:
-Setting a filter in the OnInitReport trigger does not work because the DataItem cannot be initialized. OnInitReport is the only trigger that occurs before the Request Form is displayed.
-Setting a filter in the DataItemTableView does not pass to the Request Form
There are three possible workarounds:
1. If appropriate, call the report from a form. Filter the appropriate field for the record, then pass the record to the report using RUNMODAL OR RUN()
2. Use a CodeUnit as a wrapper. Filter the appropriate field for the record, then pass the record to the report using RUNMODAL OR RUN(). If this is the only purpose of the codeunit, consider a better alternative - you are about to cost your client two objects.
3. Utilize the Options tab of the Request form.
The last option can be achieved in many ways, but I'll try to detail a the most robust solution I know how in the following example:
////////////////////////////////////////////////////
EXAMPLE
Assume that your business sells food items.
Assume your desired report displays item information, and you want to set a default filter for the Inventory Posting Group.
Your Report Designer looks like this:
Create the following global variables (note the length is up to what you think is appropriate):
Open the Request Options Form Designer. Add a text box control for IPGFilter. In the code for the text box, add the following variables to the Report - OnLookup
Add the following code to the Report - OnLookup
In the Report - OnInitReport, add the following code:
In Item - OnPreDataItem, add the following code:
With a setup like this, it is advisable to hide the DataItem's tab from showing in the report's Request Form. Do this by setting the DataItemTableView. Alternatively, block for situations where the user might try setting both.
In the Report - OnPreReport, add the following code. This may look odd, but remember that the IPGFilter has not been applied to the DataItem at this point in code
Systems Analyst
NAV 2009 R2 (6.00.34463)
In report suggest vendor payments, if you push summarize per vendor, you can choose dimensions by ticking the records you want, and it will create a filter for you. This is better than navisions normal behavior, so you won't feel bad bc you did a workaround
That's a pretty cool way of doing it, but keep in mind this solution involves the report, a table, a form, and two codeunits (which could technically be consolidated to one codeunit). It is an incredibly robust, elegant solution, but you just paid for 4-5 objects... does the solution warrant the cost? As always, you'll need to make the determination.
Systems Analyst
NAV 2009 R2 (6.00.34463)