SETFILTER - Using Wildcard *

TFCrowther
Member Posts: 35
Applying the SETFILTER using a Wildcard filter against a value from another field does not work.
For example if the OtherFieldValue is another field from a different table and you need to filter a text field for names begining with the letter 'G'
You would expect the SETFILTER to return only records begining with 'G'
OtherFieldValue := 'G';
SETFILTER(name,'%1*',OtherFieldValue);
This does not work
A way around this is to use the STRSUBSTNO to include the WILDCARD
SETFILTER(name,'%1',STRSUBSTNO('%1*',OtherFieldValue));
For example if the OtherFieldValue is another field from a different table and you need to filter a text field for names begining with the letter 'G'
You would expect the SETFILTER to return only records begining with 'G'
OtherFieldValue := 'G';
SETFILTER(name,'%1*',OtherFieldValue);
This does not work
A way around this is to use the STRSUBSTNO to include the WILDCARD
SETFILTER(name,'%1',STRSUBSTNO('%1*',OtherFieldValue));
0
Comments
-
This is already enough:
SETFILTER(name,'%1',OtherFieldValue + '*');
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!1 -
Belias, this I gues doesn't work in any Navision version.0
-
Belias wrote:Another info if you do not know: in version 3.10 (and below i suppose) if you apply a filter like <>A*, it doesn't work!(from code and also using F7 on a field)Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Tested in a 3.60sql db and not working...
5.0fdb not working...
4.0sp1 sql working...
3.70 sql working...so.......................
only in version 3.70 and above, for sql DBs only, filters like <>A* works!0 -
Hi,
I am using Nav. 4.0 SP2 SQL DB.
I am having a problem with using setfilter with *
SETFILTER(Field,'%1',STRSUBSTNO('%1*',TEXTVALUE));
OR
SETFILTER(Field,'%1*',TEXTVALUE);
I am having an error message:
The Filter cannot have question mark(?),asterisk(*), or 'at' sign (@)
thanks,
archaingelsGod loves us!!!0 -
On what type of field you are using the filter?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
In some cases the "parameter replacement" is not working (it means that the string '%1' is not replaced by the parameter value). This is known bug since version 2.x and you can check that by checking the filter value after you set the filter (e.g. through MESSAGE('%1',GETFILTERS).
"Kine" wrote the lines above in the topic below, I hope it will definitively complete this "tips & trick" topic
I Wrote:Tested in a 3.60sql db and not working...
5.0fdb not working...
4.0sp1 sql working...
3.70 sql working...so.......................
only in version 3.70 and above, for sql DBs only, filters like <>A* works!
I was talking about inserting filters within the mask (user's side - F7).
In C/AL code you must handle wildcards in the way written in the link below. Hope this helps!
http://www.mibuso.com/forum/viewtopic.php?t=23219&highlight=0 -
Hi everyone!
I'm using Navision financial 2.65.
I'm trying to search for this string in the database:
@ahoo.com
.SETFILTER(Email,'%1','@ahoo.com'); -> not working (couse: @ - special char)
.SETFILTER(Email,'%1','*ahoo.com'); -> not working (couse: dont give back the exact result)
Are there any "ESCAPE" character in Navision I can use.
Thanks for the help.
not SQL database....0 -
kriki wrote:SETRANGE(Email,'@ahoo.com');
or also
SETFILTER(Email,'%1','?ahoo.com');
the SETRANGE is generally better for performance.
I suppose he wants *@ahoo.com...
BTW...meehi, did you try with the find/replace(or replace all) feature with @ahoo.com keyword?
oh! damn it!this topic is double posted in navision too!
edit: not really...only the question is duplicated0 -
Belias wrote:kriki wrote:SETRANGE(Email,'@ahoo.com');
or also
SETFILTER(Email,'%1','?ahoo.com');
the SETRANGE is generally better for performance.
I suppose he wants *@ahoo.com...
BTW...meehi, did you try with the find/replace(or replace all) feature with @ahoo.com keyword?
oh! damn it!this topic is double posted in navision too!
edit: not really...only the question is duplicated
continue this here:
http://www.mibuso.com/forum/viewtopic.php?p=125500#1255000 -
I have also a question concerning this topic. I'm making in NAV4.6 a report, in which I generate a list of my articles, my articles all have an alphanumeric No. and I want to filter out the article No.'s containing the combination 'PIP'. I thought this would be easy by inserting a predifined filter in Table View -> No. <> *PIP*. But this didn't seem to work. Then I tried to insert a line of code at the DataItem 'Item', to skip the records containing 'PIP' by:
IF "Item"."No." = '*' + 'PIP' + '*' THEN CurrReport.SKIP; but it didn't seem to work. Can someone give me a hint!?"Make it idiot-proof and someone will invent a better idiot..."0 -
does nav 4.6 exists? :shock:
anyway...in a sql db 4.01 it works
also: the code you wrote is wrongIF "Item"."No." = '*' + 'PIP' + '*' then currreport.skip;
with this code you skip THE item named *PIP*...in other words...you're not setting a filter with this code!!
the correct code to achieve your goal is this (use it only if the filter does not work, as it is slow)IF strpos("Item"."No.",'PIP') <> 0 then currreport.skip;
see the online help for strpos function0
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