Problem searching for string containing ampersand

Jay2007
Member Posts: 50
Hi there,
I have a form with a search field on it used to search on the Item description field. When the user enters text in this field I use the following code to search for any item descriptions that contain this text within it :-
SearchStr := '@*'+"Search Field"+'*';
Item.SETFILTER( Description, Search Field );
The problem with this is that the search yields nothing if the search string contains an ampersand (&) in it.
Does anyone have a workaround for this?
Thanks,
Jay
I have a form with a search field on it used to search on the Item description field. When the user enters text in this field I use the following code to search for any item descriptions that contain this text within it :-
SearchStr := '@*'+"Search Field"+'*';
Item.SETFILTER( Description, Search Field );
The problem with this is that the search yields nothing if the search string contains an ampersand (&) in it.
Does anyone have a workaround for this?
Thanks,
Jay
0
Answers
-
change the ampersand to question mark.0
-
I just retested it in sql and native and it works fine . In cronus it returned 1 record.
searchstr := '*@n&G*'; customer.setfilter("name",searchstr); message(format(customer.count));
Then changed it tosearchstr := '*@n&g*'; customer.setfilter("name",searchstr); message(format(customer.count));
It didn't work on native, but worked fine on sql.
So you could use "Search Description" field and make the searchstr all UPPERCASE. Or create a new field and make it Code type and copy of description and search on that.0 -
If you have a collation that is not case sensitive though it should return the same.0
-
That works perfectly Peter. Thanks very much for that !!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