OR case for record filtering

kenl
Member Posts: 182
Hello,
How can we set "OR" case record filtering ?
Eg. on table 18 Customer, I would like to filter records that are
1) Country Code = 'US'
OR
2) Balance (LCY) > 0
If I write something like this:
Customer.SetFilter("Country Code", 'US');
Customer.SetFilter("Balance (LCY)", '>0');
This would give me the "AND" case.
Any idea?
:-k
How can we set "OR" case record filtering ?
Eg. on table 18 Customer, I would like to filter records that are
1) Country Code = 'US'
OR
2) Balance (LCY) > 0
If I write something like this:
Customer.SetFilter("Country Code", 'US');
Customer.SetFilter("Balance (LCY)", '>0');
This would give me the "AND" case.
Any idea?
:-k
0
Comments
-
there is no direct way to OR filters, i think, but try to patch the wanted records together by using the mark mechanism:
Customer.SetFilter("Country Code", 'US'); if Customer.find('-') then repeat Customer.Mark(true); until next = 0; Customer.SetRange("Country Code"); Customer.SetFilter("Balance (LCY)", '>0'); if Customer.find('-') then repeat Customer.Mark(true); until next = 0; Customer.SetRange("Balance (LCY)"); Customer.MarkedOnly(true);
maybe it's not very performant, but on small to medium tables it works :?0 -
Hello Toenne ,
Thanks for your idea.
Ken
[/code]0 -
Or....
You could create a Temporary record and insert all records that apply to your filtering.Cust.FIND('-'); REPEAT IF (foo = bar) OR (bar = foo) THEN BEGIN TEMPCust := Cust; TEMPCust.INSERT; END; UNTIL Cust.NEXT = 0; FORM.RUNMODAL(0, TEMPCust);
* Code has not been tested.
BTW, Marking records perform perfectly as long as you select the primairy key. If you need to set another key it's better to you code above... I think..."Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."0 -
eromein wrote:[...]
BTW, Marking records perform perfectly as long as you select the primairy key. If you need to set another key it's better to you code above... I think...
You should have the best key dependend to your filter.
Before you set Cust.MARKEDONLY := TRUE it is recommended to change the key to the primary key because with that key you get the best performance for viewing the records.Timo Lässer
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]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