SETFILTER using a String with integers
McMercy
Member Posts: 7
Hello!
How do I have to code the following filter:
IF TableInput.FIND ('-') THEN BEGIN
REPEAT
strFilter := strFilter + Format( TableInput.TableID) + '|';
UNTIL TableInput.NEXT = 0;
END;
SETFILTER("Object ID",'%1',strFilter);
The Filter should filter by Objekt ID which is an integer, of course strFilter is a string with a list of integers linked with |. Navision refuses to do this, what is the correct synthax?
Thanks
How do I have to code the following filter:
IF TableInput.FIND ('-') THEN BEGIN
REPEAT
strFilter := strFilter + Format( TableInput.TableID) + '|';
UNTIL TableInput.NEXT = 0;
END;
SETFILTER("Object ID",'%1',strFilter);
The Filter should filter by Objekt ID which is an integer, of course strFilter is a string with a list of integers linked with |. Navision refuses to do this, what is the correct synthax?
Thanks
0
Comments
-
setfilter("Object ID", strFilter);
Note: with your loop, the variable strFilter ends with a | <- this you must eleminate.
RegardsDo you make it right, it works too!0 -
Hi McMercy,
Look to me as if the filter is build as 1|2|3| the problem is the last |
to remove the last | use
strFilter := copystr( strfilter, 1, strlen(strfilter) -1 );
How this helps
PS Welcome to Mibuso
0 -
garak wrote:setfilter("Object ID", strFilter);
Note: with your loop, the variable strFilter ends with a | <- this you must eleminate.
Regards
Dam it - Beaten again #-o - you Germany are far too efficent
0 -
sorry dave: the first problem is the way he use setfilter
the thierd parameter, the value, must have the same datatype like the field which is filtered. The filtered field is from type integer. But the value is text so the compiler would tell this.
To solved this, you can put your filterconsturct into the second parameter. Instead ofsetfilter(YourFieldIsInteger,'%1|%2|%3',1,4,6);
you can also writesetfilter(YourFieldIsInteger,'1|4|6);
but notsetfilter(YourFieldIsInteger,'%1','1|4|6');
the second problem in this code is, see in the first post, that the variable strFilter ends with a | <- the last pipe must be eleminated
regardsDo you make it right, it works too!0 -
no comment ;-) :whistle:Do you make it right, it works too!0
-
:oops: missed the setfilter problem - just like the compiler I stopped when I hit the first problem
0 -
Nearly There but as said the last pipe "|" is a problem, but the solution is simple.
1st problem there might be only one record, so we have to code for this.
2nd the Pipe "|" has to come before the the string, but not for the First Record, so we add a counter, and change the string based on its value.J := 0; IF TableInput.FIND ('-') THEN REPEAT j := j + 1; IF j := 1 THEN strFilter := Format( TableInput.TableID) ELSE strFilter := strFilter + '|' + Format( TableInput.TableID); UNTIL TableInput.NEXT = 0;
Hope this helps!
DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
Hello,
is that possible to filter...constructing a string as the previous... but with <> (not equal ) from a list?
SETRANGE("Purch.Order Line No.", '<>%1', myString) ?
with my String = 'A|B|C...'
Or which is the right syntax?
myString = '<>A|<>B|<>C ...'
Thank you0 -
You need to use AND between each part. it means '<>A&<>B&<>C' else it will be true in all cases...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
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 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
