Strange behavior in SETFILTER

Egnaz
Member Posts: 111
Hi there,
I wanted to use a simple SETFILTER like this SETFILTER("No.",'%1*',MyNo)
But this filter won't work as intendet. The result from ERROR(GETFILTERS) is Filter: "No."=*
I had to a workaround to get it working for me. SETFILTER("No.",'%1',MyNo + '*') works and I get my correct filter.
Tested on NAV2009 SP1.
Any ideas why it won't work?
Greetz
egnaz
I wanted to use a simple SETFILTER like this SETFILTER("No.",'%1*',MyNo)
But this filter won't work as intendet. The result from ERROR(GETFILTERS) is Filter: "No."=*
I had to a workaround to get it working for me. SETFILTER("No.",'%1',MyNo + '*') works and I get my correct filter.
Tested on NAV2009 SP1.
Any ideas why it won't work?
Greetz
egnaz
0
Answers
-
Hmmm ... I had the same problem last week. Found the solution in the forum somewhere.
But you could try SETFILTER("No.",'%1','*' + MyNo)0 -
Did you try SETFILTER("No.",'%1*',MyNo);0
-
Thereis one old bug since version 2.x, when the %1 in the string is not replaced with the parmeter when there is something behind this placeholder. I have already described it somewhere... :-k0
-
After some research I found the KB article 951233
Official the bug is since NAV 4:MS KB 951233 wrote:SYMPTOMS
Consider the following scenario. You use the C/AL command SETFILTER in Microsoft Dynamics NAV 4.0. The filter includes a wildcard character and a field replacement. For example, the wildcard character is an asterisk or a question mark. In this scenario, the filter may not be applied correctly.
CAUSE
This problem occurs because Microsoft Dynamics NAV 4.0 cannot handle wildcard characters when it applies a filter and must perform a field replacement action in the filter.
WORKAROUND
To work around this problem, separate the field replacements into a different step. For example, you use the following command:Rec.SETFILTER("No.",'%1*','100');
Note You can use %N as a field replacement. N represents a number.
Microsoft Dynamics NAV 4.0 replaces %1 with 100. Therefore, the command resembles the following command:Rec.SETFILTER("No.",'100*');
If you change the C/AL code to have specific filters as in this example, the SETFILTER command works as expected.
To avoid the problem that is described in the "Symptoms" section, make sure that you do not combine field replacements (%) with wildcard characters. If you must use such a combination, convert the filter into a string. Then, use the string as the filter instead.
For example, you use the following command:Item.SETFILTER("No.",'%1*','100');
Change the command to use the string as follows:TempString := STRSUBSTNO('%1*','100'); Item.SETFILTER("No.",TempString);
Thanks to all.
Hopefully the "bug" will be fixed in one of the next releases.
Regards,
Egnaz0 -
Ohhh my g0d :sick:
Wheres that smiley with the wall - ohh there it is
](*,) ](*,)
I've been dealing with this little thing for half the day, thought I was dumb
5.0 it has'nt been fixed, well now I know!Best regards / Venlig hilsen
Johannes Sebastian
MB7-840,MB7-8410
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