Problem with SETFILTER, OR operator

nara
Member Posts: 37
Hi!
I need some help about a SETFILTER.
I have an Itemrecord that I want to filter by Class in such way that my Itemrecord included item that have these (several) class value.
What could be equivalent to one of the following SQLquery
select * from Item where Calss in ('class1', 'class2'..... , 'classn')
OR
select * from Item where Class = 'class1' OR Class = 'class2'..... OR Calss = 'classn'
I want some thing like that in my CODEUNIT
ItemRecord.SETFILTER("Class", and I do not no how to handle the rest :oops: );
best ergards
Nasser
I need some help about a SETFILTER.
I have an Itemrecord that I want to filter by Class in such way that my Itemrecord included item that have these (several) class value.
What could be equivalent to one of the following SQLquery
select * from Item where Calss in ('class1', 'class2'..... , 'classn')
OR
select * from Item where Class = 'class1' OR Class = 'class2'..... OR Calss = 'classn'
I want some thing like that in my CODEUNIT
ItemRecord.SETFILTER("Class", and I do not no how to handle the rest :oops: );
best ergards
Nasser
0
Comments
-
first: You are in the wrong forum section :-)
second try following:ItemRec.Setfilter("Class",'%1|%2|%3','TABLE','STOOL','CHAIR');
if you need the filter dunymicly, you can fill a variable and use the variable as filter
RegardsDo you make it right, it works too!0 -
Note that the maximum filterstring length is 250 characters, so you can't do that forever. I've seen programming like that fail because the required filter is too long.0
-
[Topic moved from Navision Tips & Tricks to Navision forum]0
-
Typically what you have to do is build the string dynamically, all the while checking to see if you have exceeded 250 characters. Once you exceed you build another string for the reminder (and so on). Then you get all of your mutually exclusive result sets and push them all into a temporary record.
A huge pain, but it works.
Usually people do this kind of thing when they want to do something like a SQL join ( or a select * where in) in NAV, but they can't.
For small data sets, it makes sense to just loop through all of the items, and insert them into a temporary record if they match your criteria.
For larger data sets, your best option is use to use ADO. When using ADO remember to build your SQL string in NAV and not use a stored procedure.
Getting into the mess of managing stored procs. just so you can make one query is a huge waste of time.0 -
Just for a sense of scale... to me a large data set would be where you have a GB or so of items.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