Can you think of any issue with simply replacing special characters with the asterisks (*)? The reason I ask is that I know that's the wildcard identifier when filtering, but it worked when I needed to search for a vendor with and ampersand (&) in the name, so I tried it for one with the single quotes and it worked fine as well. Examples below:
string vendorName1 = "Triple 'C' Ranch";
string vendorNameEscape = EscapeSpecialCharacters(vendorName1); // gets transformed to "Triple %27%27C%27%27 Ranch" <-- this worked
string vendorNameWildcard = ReplaceWithWildcard(vendorName2); // gets transformed to "Triple *C* Ranch" <-- this worked
string vendorName2 = "ADP SCREENING & SELECTION SERVICES";
string vendorNameEscape2 = EscapeSpecialCharacters(vendorName2); // gets transformed to "ADP SCREENING %26%26 SELECTION SERVICES" <-- does NOT work
string vendorNameWildcard2 = ReplaceWithWildcard(vendorName2); // gets transformed to "ADP SCREENING * SELECTION SERVICES" <-- this worked
I can't think of any negative impacts to using this method as it retrieves the record I am looking for and bypasses the method of finding the escaped version of the character. And, in my tests, the escaped version of the ampersand did not work (any ideas as to why not?).
I even was able to simple apply Regex to my function to identify and replace the characters and after about 9 tests, it looks as though the query system in BC works just fine with the * character in multiple places of the search string. My function below:
public string CleanFilter(string filter)
{
return Regex.Replace(filter, "[^a-zA-Z0-9]", "*");
}
This uses System.Text.RegularExpressions namespace and this is the constructor I used.