Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: How to edit search query?!

  1. #1
    Yasso's Avatar
    Yasso is offline Sugar Community Member
    Join Date
    Jan 2010
    Location
    Syria
    Posts
    71

    Default How to edit search query?!

    Hey Guyz
    I'm using Sugar 5.5

    I have 2 similar dropdowns with same values
    and I want customize the search so I can search in both of them as 1 field like:

    as an example:
    I have billing address city and other address city

    I want when I search for a city, to search in both fields
    any idea
    plus where is the search query is saved so I can edit

    Thanks in advance

    Yassin,

  2. #2
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,678

    Default Re: How to edit search query?!

    I did that in /include/MVC/View/views/view.list.php in function processSearchForm().

    Ther you can modifiy the $where_clauses array.

    You can also define own view.list.php files in /custom/modules/<modul>/views/
    Harald Kuske
    Senior Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com

    PLEASE SWITCH TO
    https://community.sugarcrm.com/, the FORUMS will be closed !


  3. #3
    Yasso's Avatar
    Yasso is offline Sugar Community Member
    Join Date
    Jan 2010
    Location
    Syria
    Posts
    71

    Default Re: How to edit search query?!

    Thanks

    But actually I didn't know what to do :S I'm still new

  4. #4
    christianknoll's Avatar
    christianknoll is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Vienna
    Posts
    1,382

    Default Re: How to edit search query?!

    Simplest thing would be to either read the manual or get somebdy porfessional to help you .. ;-) ...

    Quote Originally Posted by Yasso View Post
    Thanks

    But actually I didn't know what to do :S I'm still new

  5. #5
    Yasso's Avatar
    Yasso is offline Sugar Community Member
    Join Date
    Jan 2010
    Location
    Syria
    Posts
    71

    Default Re: How to edit search query?!

    I need to know where the search queries are stored I didnt find them

    and if you have any suggested solution how to merge the filed in search

  6. #6
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,678

    Default Re: How to edit search query?!

    Try this:

    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);
    //KUSKE
    // New additinal code:
    //          #################################################
                
    if ( $this->seed->module_dir == "Accounts" )
    //          #################################################
                
    {
                   foreach(
    $where_clauses as $dakey => $dawert) {
                      if(
    strpos($dawert,"billing_address_city") !== false)
                      {
                         
    $city_clause_old $where_clauses[$dakey];
                         
    $city_clause_new  "(";
                         
    $city_clause_new .= $city_clause_old;
                         
    $city_clause_new .= " OR ";
                         
    $city_clause_new .= str_replace ("billing","shipping",$city_clause_old);
                         
    $city_clause_new .= ")";
                         
    $where_clauses[$dakey] = $city_clause_new;
                      }
                   }
                }
    //KUSKE
    ... 
    Harald Kuske
    Senior Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com

    PLEASE SWITCH TO
    https://community.sugarcrm.com/, the FORUMS will be closed !


  7. #7
    christianknoll's Avatar
    christianknoll is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Vienna
    Posts
    1,382

    Default Re: How to edit search query?!

    for an easy example look into modules/Accounts/metadata/SearchFields.php. The Address Data is handled like that and you will see how an array definition in the searhfielddefs will accomplish what you are looking for.

    christian.

    Quote Originally Posted by Yasso View Post
    I need to know where the search queries are stored I didnt find them

    and if you have any suggested solution how to merge the filed in search

  8. #8
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,678

    Default Re: How to edit search query?!

    Ok,
    Christian is right.
    My way works but the built in method is to use the address_city field.
    I saw the trees but not the forest .

  9. #9
    Yasso's Avatar
    Yasso is offline Sugar Community Member
    Join Date
    Jan 2010
    Location
    Syria
    Posts
    71

    Default Re: How to edit search query?!

    Thanks Guys I think I got it now

    in the custom/modules/accounts/metadata/searchdefs.php

    I have the following field that I want to select the value
    PHP Code:
    'biz_activity_first_c' => 
          array (
            
    'type' => 'enum',
            
    'default' => true,
            
    'studio' => 'visible',
            
    'label' => 'LBL_BIZ_ACTIVITY_FIRST',
            
    'width' => '10%',
            
    'name' => 'biz_activity_first_c'
    and
    modules/Accounts/metadata/SearchFields.php the following

    PHP Code:
    'biz_activity_first_c'=> array('query_type'=>'default','db_field'=>array('biz_activity_first_c','biz_activity_first2_c','biz_activity_first3_c','biz_activity_first4_c','biz_activity_first5_c','biz_activity_first6_c',)), 
    because I have 6 fields I want to search in
    and IT WORKED
    you're really amazing guyz

    is there anything additional I should do and all my steps were correct right?
    you I owe you guys


    Yassin

  10. #10
    Big Ring's Avatar
    Big Ring is offline Senior Member
    Join Date
    Sep 2009
    Location
    Minnetonka, MN, USA
    Posts
    44

    Default Re: How to edit search query?!

    I am trying to do a similar thing on three custom fields in the Cases module and tried the same thing that Yasso did -- except I get an error that looks like this:
    SQL Error : The data types text and nvarchar are incompatible in the is operator.
    All three fields are DropDown fields (enum) that reference the same list. Did I miss something?

    Is it that I am using M$ SQL instead of MySQL? How can I fix this?
    Thanks,

    Tim

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. where to edit the query?
    By Jerrym in forum Developer Help
    Replies: 3
    Last Post: 2009-03-02, 11:30 AM
  2. Quick Search Query Customization
    By consultsales in forum General Discussion
    Replies: 0
    Last Post: 2008-12-02, 01:47 PM
  3. Replies: 0
    Last Post: 2008-11-03, 08:33 AM
  4. How to get the query of saved search functionality...?
    By maniram2202 in forum Developer Help
    Replies: 0
    Last Post: 2008-10-15, 01:20 PM
  5. Search Query
    By manahar in forum Developer Help
    Replies: 0
    Last Post: 2007-07-16, 07:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •