SETFILTER vs. DataItemTableView

afarr
Member Posts: 287
In a report, can DataItemTableView always be replaced by SETCURRENTKEY and SETFILTER (in the OnPreDataItem trigger)?
Maybe this would affect PrintOnlyIfDetail (of a higher data item) or grouping?
Thanks,
Alastair
Maybe this would affect PrintOnlyIfDetail (of a higher data item) or grouping?
Thanks,
Alastair
Alastair Farrugia
0
Comments
-
Its pretty much the same...
Why did you decide to use code instead of DataItemTableView and what do you mean "affect"?0 -
Hi Gmc,
I have a Sales Order report, with
WHERE(Document Type = CONST(ORDER))
in its DataItemTableView.
I wanted to use this report also for Sales Invoices. What I did in fact was:
SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type");
REPORT.RUN(ReportID,TRUE,FALSE,SalesHeader);
The report's Filter Form now shows this filter (even though "Document Type" is not included in ReqFilterFields) but that's OK.
AlastairAlastair Farrugia0 -
Thats what I think...
The reports DataItemTableView will set the additional filter into Document Type = CONST(ORDER)) and you won't get Invoices there... Even if you put it OnPreDataItem, the filter in the DataItemTableView will be set.0 -
Gmc wrote:Even if you put it OnPreDataItem, the filter in the DataItemTableView will be set.
Not entirely, Gmc.
Affar, you can easily replace DataItemTableView filter by using SETFILTER or SETRANGE OnPreDataItem.
But you should use FILTERGROUP at first.
The matter is that when you use SETRANGE or SETFILTER by default you use FILTERGROUP 0. And the DataItemTableView filter uses FILTERGROUP 2.
So, all you need before SETRANGE is to set FILTERGROUP to FILTERGROUP 2.
Here is the code you should write OnPreDataItem:"Sales Header".FILTERGROUP(2); "Sales Header".SETRANGE("Document Type", "Sales Header"."Document Type"::Invoice);
0 -
Gms
delirium0 -
and do read help about setfilter, setrange, filtergroup and datatableview properties, etc...
it will be much easier to use this functions when you understand them.®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯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