Always add a wildcard at beginning of a search term

sugarcrmdevelopers —  July 26, 2013

There was a question on the SugarCRM forums today that asked if anyone has found an upgrade-safe way to customize searches to always add a % to the beginning of a search ( Being able to add a wildcard is useful if you are searching for something that may exist in the middle of a value and not necessarily at the beginning. For example, you know a lead you’ve been working on contains “Auto” in it, but you aren’t sure where. You can manually search for %Auto and it will return any lead that contains “Auto” anywhere in the name. (FYI – the search wildcard is always added to the end of a search)

Some would prefer that the search always act this way. In the past, a hack had to be done to include/SearchForm/SearchForm2.php. Since that time, SugarCRM has added a global config option. Simply add the following to your config_override.php:

'search_wildcard_infront' => true,

There are tons of undocumented or hard to find documentation on options such as this. If enough people would find it useful I’d be willing to take a shot at writing a parser that extracts nuggets such as this from the code.