Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Grouping of accounts or contacts

  1. #1
    the stig is offline Sugar Community Member
    Join Date
    Nov 2006
    Posts
    10

    Default Grouping of accounts or contacts

    Is there a way to group contacts. Let's say i want to make my own classifications like "send accound a cristmas card" or more crm like "account was on last meeing". And afer this you can assign accounts on this classification so you can get a list of all accounts who where on the last meeting or something like that.

    Is this way of grouping possible in Sugar or with any plugin/addon? Or should i use a pro version, i am using the opensource version.

    Kind regards

    Erik Klaassen

  2. #2
    atheimer98 is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    202

    Default Re: Grouping of accounts or contacts

    The easiest way IMO is to create a custom field that contains a managed dropdown list. Than you can mass-update
    using the search criteria to move accts or contact between groups. Otherwise look for the power prospecting module
    which works well for creating lists.

  3. #3
    the stig is offline Sugar Community Member
    Join Date
    Nov 2006
    Posts
    10

    Default Re: Grouping of accounts or contacts

    Tanks for the fast answer, I'll try around...

    Erik

  4. #4
    the stig is offline Sugar Community Member
    Join Date
    Nov 2006
    Posts
    10

    Default Re: Grouping of accounts or contacts

    Allright, i've done some thinks. I made a multiple select custom field and added this field into the accouts page. I added it on the detail view, edit view, in the additonal list on the list view and last on de search form.

    I made a list with some test data: "was on last meeting", "is a customer of john", "is a customer of jane"......

    Then i edited a accound and selected "was on last meeting" and "is a customer of john". Next thing i selected "was on last meeting" and "is a customer of jonh" in the search form but it didn't return with my just edited account.

    Point is, i want to search all accounts who where on the last meeting and are a customer of john (for example)

    When i select just one cassification it works fine but i just need more...

    I hope you can help me with te next step...

    Regards,

    Erik

  5. #5
    the stig is offline Sugar Community Member
    Join Date
    Nov 2006
    Posts
    10

    Default Re: Grouping of accounts or contacts

    Someone please?

  6. #6
    heaveyb is offline Member
    Join Date
    Nov 2006
    Posts
    6

    Default Re: Grouping of accounts or contacts

    Erik
    Had same problem
    See this thread for solution from Martin Haber
    http://www.sugarcrm.com/forums/showt...ferrerid=44179
    Hope that helps
    Ben

  7. #7
    the stig is offline Sugar Community Member
    Join Date
    Nov 2006
    Posts
    10

    Default Re: Grouping of accounts or contacts

    wow nice code.
    But it is working like sql and statement and i'am looking for something that works like a or statement.

    I tried to replace the and by or's but that didn't work either.

    I made a company1 that is "test1" and "test2". and another company2 that is "test2" and test3" When is search for accounts that are "test1"and test2 i get both accounts. But i only want company1.

    What should i do?

    tanks in advance

  8. #8
    martin.huber@canoo.com is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    18

    Default Re: Grouping of accounts or contacts

    Hi Stig,

    if you want a "and"-search for the multi-form params you have to do 2 things:

    1. replace the single " OR" in between the 2 comments with " AND"
    2. locate a code block above the one I introduced, that is looking pretty much like that
    if(is_array($parms['value'])) {
    foreach($parms['value'] as $key => $val) {
    if($val != ' ' and $val != '') {
    ....

    - it is the only other place with that "is_array" check, ...

    That code fragment introduces an OR statement like:
    OR field_value in {"test1, "test2"{
    that would disturb the behaviour you are intending (in the case, the custom field only contains exactly one value, either "test1" or "test2" it would return both records what again would be like an or search)
    => just comment out that upper block !

    Hope that helps,
    best regards,
    Martin

  9. #9
    the stig is offline Sugar Community Member
    Join Date
    Nov 2006
    Posts
    10

    Default Re: Grouping of accounts or contacts

    I am sorry, i don't get it....
    I located this code :
    PHP Code:
       if(is_array($parms['value'])) {
                           foreach(
    $parms['value'] as $key => $val) {
                           if(
    $val != ' ' and $val != '') {
                              if(!empty(
    $where)) {
                                    
    $where .= " OR ";
                                }
                                
    $where .= " locate('" $GLOBALS['db']->quote($val) . "',$db_field)>0 " ;
                            }
                        }
                    }



                            
    $itr++;
                            if(!empty(
    $where)) {
                                
    $where .= " OR ";
                            } 
    Which OR needs to be a AND?
    And what sould be commended out?

    Erik

  10. #10
    martin.huber@canoo.com is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    18

    Default Re: Grouping of accounts or contacts

    Your code in "include/SearchForm/SearchForm.php" should look like this:

    From line 182
    PHP Code:
               if(isset($parms['value']) && $parms['value'] != "") {
                    
    $operator 'like';
                    if(!empty(
    $parms['operator'])) {
                        
    $operator $parms['operator'];
                    }
                    if(
    is_array($parms['value'])) {
    // comment this block out as this builds the in query: "... field_value IN {'test1', 'test2'}
    // we will build another query later
    //                    $operator = 'in';
    //                    $field_value = '';
    //                    foreach($parms['value'] as $key => $val) {
    //                        if($val != ' ' and $val != '') {
    //                            if (!empty($field_value)) {
    //                                $field_value .= ',';
    //                            }
    //                            $field_value .= "'" . $GLOBALS['db']->quote($val) . "'";
    //                        }
    //                    }
                    
    }
                    else {
                        
    $field_value $GLOBALS['db']->quote($parms['value']);
                    } 
    and at the bugfix at line 260, that is implementing the OR lookup for the selected search fields:
    PHP Code:
    if($GLOBALS['db']->dbType == 'oci8' && isset($parms['query_type']) && $parms['query_type'] == 'case_insensitive') {
                                  
    $db_field 'upper(' $db_field ")";
                                  
    $field_value strtoupper($field_value);
                            }
    // bugfix, line 260, include/SearchForm/SearchForm.php:
    // test for every multi select parameter, if it is a substring of the field:
    // @stig: you need to build sql of the form:
    // ( locate('term1', FIELD)>0 AND locate('term2', FIELD)>0 ... )
                    
    if(is_array($parms['value'])) {
                        foreach(
    $parms['value'] as $key => $val) {
                            if(
    $val != ' ' and $val != '') {
                                if(!empty(
    $where)) {
    // @stig this has to be the AND
                                    
    $where .= " AND ";
                                }
    // @stig probably it is the best to have the and expression in ( ) 
                                
    else {
                                    
    $where .= " ( ";
                                }
                                
    $where .= " locate('" $GLOBALS['db']->quote($val) . "',$db_field)>0 " ;
                            }
                        }
    // @stig and close it again: 
                       
    if(!empty($where)) {
                               
    $where .= ")";
                       }
                    }
    // end bugfix: test for every multi select parameter, if it is a substring of the field

                            
    $itr++;
                            if(!empty(
    $where)) {
                                
    $where .= " OR ";
                            } 
    Best regards,
    Martin

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

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
  •