Adding filters to report

Hohenzollern
Member Posts: 18
Hi to all,
Have some problems with creating of report. For example, have 2 tables - "Employee" and "Pers"(have some key fields from Employee).
Data from those tables have to be shown in report, on pressing special button, that is on the form.
I can set filter in such a way
Tell me please, where I can read or find an example of what I need.
I'm still learning, thx for any help)
Have some problems with creating of report. For example, have 2 tables - "Employee" and "Pers"(have some key fields from Employee).
Data from those tables have to be shown in report, on pressing special button, that is on the form.
I can set filter in such a way
Employee.SETRANGE("No.",Rec."Pers"); REPORT.RUN(REPORT::"Test Report",TRUE,FALSE,Employee);But I don't know how to set several filters, executed on 1 REPORT.RUN.
Tell me please, where I can read or find an example of what I need.
I'm still learning, thx for any help)
0
Comments
-
With this statement it's possible to manage only one record variable, you need to use a Report variable and pass the filters with a function:
Employee.FILTERGROUP(10); Employee.SETRANGE("No.",Rec."Pers"); Pers.FILTERGROUP(10); Pers.SETRANGE("Department",'IT'); TestReportVar.SetFilters(Employee,Pers); TestReportVar.RUN;
In SetFilter function remember to pass the parameter by value otherwise you'll have empty filters.
Moreover choose a non-internally used filtergroup in order to combine your filters with DataItemLink property and set them in OnPreDataItem trigger:EmployeeFilters.FILTERGROUP(10); EmployeeDataItem.COPYFILTERS(EmployeeFilters);
* Daniele Rebussi * | * Rebu NAV Diary *0 -
Thx for anwer, if you don't mind, one more question:
As I understand, I have to create function named "SetFilters", with record parameters "Employee" and "Pers". The code in it have to beEmployee.FILTERGROUP(10); Employee.SETRANGE("No.",Rec."Pers"); Pers.FILTERGROUP(10); Pers.SETRANGE("Department",'IT');
It will be activated on the onRun trigger withTestReportVar.SetFilters(Employee,Pers); TestReportVar.RUN;
Sorry if it's a stupid question, just want to make it all clear.0 -
Hohenzollern wrote:Thx for anwer, if you don't mind, one more question:
As I understand, I have to create function named "SetFilters", with record parameters "Employee" and "Pers". The code in it have to beEmployee.FILTERGROUP(10); Employee.SETRANGE("No.",Rec."Pers"); Pers.FILTERGROUP(10); Pers.SETRANGE("Department",'IT');
Not exactly, in the function you just need to copy the filters applied in the calling object from parameters record variables to global variables in the report:EmployeeGlobal.COPYFILTERS(EmployeePar); PersGlobal.COPYFILTERS(PersPar);
Which you will have to use in OnPreDataItem trigger.* Daniele Rebussi * | * Rebu NAV Diary *0 -
seems to have understood, thx once again, have a nice day)0
-
Hi Hohenzollern,
geordie taught you a more advanced technique to pass parameters to a report. If you just want to set filters for dataitems in the report programmatically, you neither need to meddle with FILTERGROUP nor need to create a function in the report to pass the parameters. Instead you can do like this:Employee.RESET; Employee.SETRANGE("No.",Rec."Pers"); TestReportVar.SETTABLEVIEW(Employee); Pers.RESET; Pers.SETRANGE("Department",'IT'); TestReportVar.SETTABLEVIEW(Pers); TestReportVar.RUN;
Done like this, the filters passed will be pre-populated in the request form, if you show it and the report is configured to accept user filter entries for the dataitem.
I find geordie's use of FILTERGROUP somewhat confusing. Setting the filter group to 10 before the function is called will later hide the filters from the user (something you did not ask for and thus might be misleading). Within the function, setting FILTERGROUP does not have any effect in this case, as COPYFILTERS copies filters from all filter groups to the same filter group in the destination respectively. So, use of FILTERGROUP is optional.
(SETTABLEVIEW, on the other hand, copies the filters from the current filter group only, but also sets the key, in the same way asEmployeeDataItem.SETVIEW(Employee.GETVIEW);0 -
Hi, vaprogvaprog wrote:I find geordie's use of FILTERGROUP somewhat confusing. Setting the filter group to 10 before the function is called will later hide the filters from the user (something you did not ask for and thus might be misleading). Within the function, setting FILTERGROUP does not have any effect in this case, as COPYFILTERS copies filters from all filter groups to the same filter group in the destination respectively. So, use of FILTERGROUP is optional.
As I write before, I'm still learning and usage of different functions sometimes isn't enough clear for me. Yesterday was the first time I saw FILTERGROUP) So you're right, that is the reason,why I didn't ask and that is misleading. But I have already read about, for example even there: http://www.mibuso.com/howtoinfo.asp?FileID=22
I find your way more comfortable for me, cause for the time being I'm not an advanced developer but trying to become)
Thx for both of your answers.0 -
vaprog wrote:Hi Hohenzollern,
geordie taught you a more advanced technique to pass parameters to a report. If you just want to set filters for dataitems in the report programmatically, you neither need to meddle with FILTERGROUP nor need to create a function in the report to pass the parameters. Instead you can do like this:
Yes, my fault because I wrongly remember some problems using SETTABLEVIEW for more than one dataitem when running a report :oops:* Daniele Rebussi * | * Rebu NAV Diary *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