How to set ReqFilterFields with default filter

sbilly
Member Posts: 231
When I run a report based on customer table, I want that its ReqFilterFields be filled with a default filter that I preset in advance.
For example :
Field Filter
Location Code Location1
Any Idea?
For example :
Field Filter
Location Code Location1
Any Idea?
0
Comments
-
If we run Sales Invoice report from Posted Invoices then No. will be automatically flown to reports reqfilterfields..
have look how it is working0 -
I know how it's working.
But in my case I must run the report from the object designer.0 -
You have to use Options tab..0
-
mohana_cse06 wrote:You have to use Options tab..0
-
You have to use Request Form..0
-
I know this is an old topic, but I'd like to respond for two reasons:
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.
See my response in this threadMichael Hollinger
Systems Analyst
NAV 2009 R2 (6.00.34463)0 -
Here is another solution:
Part 1 – Add the fields that will default on the Request Page.
1. Open the Development Environment.
2. Change the license to the Developer’s License.
3. Open the Report in Object Designer.
4. Go to a new row at the bottom of the Report Designer.
5. Click on the properties button or (Shift+F4).
6. Make sure the “UseRequestPage” Property is set to Yes.
7. Close the Property Page.
8. Select the Row where the Table Name is displayed.
9. Click on the properties button or (Shift+F4).
10. Enter the table name.
11. Click on the ellipse for the “ReqFilterFields” Property.
12. Add the fields to be filtered and click on the OK button.
13. Close the Properties window.
14. Close the report designer.
15. Say OK to compile the report.
Part 2 – Add the code to the page
1. In the Object Designer, select the Page where the report will be printed from and click on the Design button.
2. Click on View in the menu.
3. Select Page Actions.
4. Select the line where the report is shown.
5. Click on C/AL Code or (F9).
6. Click in the trigger.
7. Click on View in the menu.
8. Select C/AL Locals.
9. Enter a name for the Variable, select Record as the Data Type, and enter the Table Name for the Subtype. This is the table used in the report.
10. Close the C/AL Locals window.
11. In the trigger enter the variable name you created, a period, the function name “SETRANGE”, and in parentheses enter the field name, a comma and the field name again. Make sure the field names are in quotes. Example: ItemLedgerEntry.SETRANGE("Item No.","Item No.");
12. Repeat the previous step for every field that will be defaulted.
13. Change Rec in the REPORT.RUN command to the variable name you created.
14. Close the C/AL Editor.
15. Close the Action Designer window.
16. Close the Page Designer.
17. Click “Yes”.
18. Open the page where the report appears on the ribbon and select the row to include in the report.
19. The report filters default to the row values.
Sorry - I had really nice screen shots. I wish I could add them.1 -
There is a trick for doing this that I worked out many years ago.
-Create a report, say, "Item Filter Test" with an Item dataitem.
-Create a global variable Item2 as record, table 27.
-Create a global boolean variable RunFromSelf.
-Create a non local function SetRunFromSelf, with the only code:
RunFromSelf := TRUE;
-Close and save the report.
-Reopen in designer and add a global Report variable pointing to the same report called ThisReport
-Put something in the request options form/page, even if it's a hidden lable. This forces the request options tab form/page to be displayed, and it's page triggers to run.
-In the Request Options Form or Page, OnOpenPage/OnOpenForm trigger, add the following code:
IF NOT RunFromSelf THEN BEGIN
Item2.SETRANGE("No.",'1234');
ThisReport.SetRunFromSelf;
ThisReport.SETTABLEVIEW(Item2);
ThisReport.RUNMODAL;
ERROR('');
END;
Basically you have a report which can be run from object designer, from a menusuite, or through simple code using Report.RUN(<some repot id in a table>), which assigns it's own default filter which can be changed by the user. The report runs itself, then pops out with a blank error (the dirty part).
With more tinkering you can retain saved user filters. I'm fairly sure that in much older versions of Navision you could directly change the filters via filtergroups in the OnOpenForm trigger without having to resort to ERROR('').0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions