Hi,
Could anyone point me to how I can do a wildcard search on the accounts section.
I've tried changing www\modules\Accounts\Accounts.php with no luck.
Can anyone point me in the right direction.
Thanks.
Hi,
Could anyone point me to how I can do a wildcard search on the accounts section.
I've tried changing www\modules\Accounts\Accounts.php with no luck.
Can anyone point me in the right direction.
Thanks.
You can use "%" as a wildcard (see screenshot).
Stefan Ulrich Sauer
System Analyst
Devoteam Danet GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.de
Hi,
I wanted to change it by default in the code - could you let me know how I can do this?
Default is a search with wildcard at the end. Searching for "%something%" is the same as "%something".
You can place %-Wildcards everywhere in the searchstring, e.g. "%som%thing".
What kind of wildcard-search would you like to have instead?
Stefan Ulrich Sauer
System Analyst
Devoteam Danet GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.de
Hi,
I want to change in the code the wildcard search, so by default it searchs %searchterm% how can I do this?
I'm not sure if there's a better way to do this (there probably is), but you can get into the search queries via the view.list.php file (either the root one, at include/MVC/View/views, which modification of would not be upgrade safe, or at each module you'd like the search to modify, found at custom/modules/<module_name>/views). If you look through the processSearchForm() function, you should be able to find enough information there to be able to modify all the where clauses in your search query (the clauses are actually stored in a variable called $where_clauses i think) and search on your modified where clauses.
Robert Beckman
Software Engineer
Mirth Corporation
Strange, cant seem to find any function called processSearchForm()
I've checked the where clauses in custom/modules/<module_name>/views and I modified the one for the accounts section, but for some reason it has no impact!
n /modules/accounts/accounts.php there is a statement ...
array_push($where_clauses, "accounts.name like '%$the_query_string%'");
which I have changed to incorporate an extra % at the start - this doesn't seem to have done anything though!
The reason it may not have an impact is because the actual variable that passes the where clause to your query is your ViewList::where variable, but I found that the best way to modify this is before it gets imploded and its still in the $where_clause form in the processSearchForm() function.
I have version 6.0 Pro of SugarCRM, and in my include/MVC/View/views/view.list.php there's the function:
You can copy this function, along with any modifications to your $where_clauses and/or $this->where (I'd suggest modification of the $where_clauses where I've put the comment, however, because you don't want to wildcard everything, i.e. wildcarding an integer field is going to give you an error i believe) into whatever custom file you're creating, or you can just make the modifications into the root file (back it up first). For me, the function starts on line 244.PHP Code:function processSearchForm(){
if(isset($_REQUEST['query']))
{
// we have a query
if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
$this->searchForm->populateFromArray($this->storeQuery->query);
}
else {
$this->searchForm->populateFromRequest();
}
$where_clauses = $this->searchForm->generateSearchWhere(true, $this->seed->module_dir);
//ADD MODIFICATIONS HERE
if (count($where_clauses) > 0 )$this->where = '('. implode(' ) AND ( ', $where_clauses) . ')';
$GLOBALS['log']->info("List View Where Clause: $this->where");
}
if($this->use_old_search){
switch($view) {
case 'basic_search':
$this->searchForm->setup();
$this->searchForm->displayBasic($this->headers);
break;
case 'advanced_search':
$this->searchForm->setup();
$this->searchForm->displayAdvanced($this->headers);
break;
case 'saved_views':
echo $this->searchForm->displaySavedViews($this->listViewDefs, $this->lv, $this->headers);
break;
}
}else{
echo $this->searchForm->display($this->headers);
}
}
Robert Beckman
Software Engineer
Mirth Corporation
Hi Rob,
So I just need to add code as follows?
How exactly can I modify it to do a LIKE statement?
$where_clauses[0] = '%' . $where_clauses[0] . '%'
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks