Union filter
Cem_Karaer
Member Posts: 281
Hi all,
I have a table which contains two boolean fields say A and B.
To filter out only A clicked rows I can use:
(Using option field instead of two boolean fields is not applicable)
I have a table which contains two boolean fields say A and B.
To filter out only A clicked rows I can use:
Table.SETRANGE(A,true) Table.SETRANGE(B,false)To filter out only B clicked rows:
Table.SETRANGE(A,false) Table.SETRANGE(B,true)To filter out only A AND B clicked rows:
Table.SETRANGE(A,true) Table.SETRANGE(B,true)Here's the question: What about A OR B clicked rows?
(Using option field instead of two boolean fields is not applicable)
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 2005
Dynamics NAV Developer since 2005
0
Comments
-
Table.SETRANGE(A,true); if Table.findset(false,false) then begin repeat Table.mark(true); until Table.next = 0; end; Table.SETRANGE(A); Table.SETRANGE(B,true); if Table.findset(false,false) then begin repeat Table.mark(true); until Table.next = 0; end; Table.SETRANGE(B); Table.markedonly(true);
orTempTab.deleteall; Table.SETRANGE(A,true); if Table.findset(false,false) then begin repeat TempTab.Identifer := Table.Identifer; TempTab.insert; until Table.next = 0; end; Table.SETRANGE(A); Table.SETRANGE(B,true); if Table.findset(false,false) then begin repeat if not TempTab.get(Table.Identifer) then begin TempTab.Identifer := Table.Identifer; TempTab.insert; end; until Table.next = 0; end; or without the filter (Field A / B) but with a if statement in the loop Now you can loop throug you temptab. other way: new field wich stores the value := A OR B
Hope it's understandable.
RegardsDo you make it right, it works too!0 -
I think you need a new (third) field, which would not show on the form.
OnValidate of both of your current fields, you call a function:
NewFunction
FieldC := fieldA OR fieldB;
then you filter on field C, which will contain TRUE if A or B is ever TRUE.0 -
Can I use FILTERGROUP function for this purpose?Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050 -
It really doesn't apply here (in the sense that you cannot use it to do an OR) - unless you are trying to hide the filter that is on fieldC. Then you can use it.
Filtergroup just hides filters from the user (and other parts of the code).
Generally speaking, you can't have a SELECT statement with an OR in Navision. You have to filter on a field, you can't filter on fieldA = X OR fieldB = Y.
There are ways with temporary tables, looping through the data once for each condition, but this could take a long time depending on how much data you have, and the solution here is a bit simpler.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions