CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom Search that includes smart group data, odd behavior
Pages: [1]

Author Topic: Custom Search that includes smart group data, odd behavior  (Read 784 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Custom Search that includes smart group data, odd behavior
May 28, 2013, 08:58:00 am
I have a custom search that allows the end-user to filter on any group or groups.  This includes smart groups and regular groups.   This is working fine if the end-user directly runs the custom search.  If they filter on an existing smart group ( named "group abc"), then  save it as a new smart group (I named it 'group XYZ' ) it  works if they click "Contacts ... Manage Groups" then click the "contacts" hyperlink for that group. (they get the expected list of contacts.)

If the user clicks "Search ... Find Contacts" and filters on group XYZ, then they get an empty result set, as it seems to be ignoring the custom search filter for including contacts in "group abc".

I think the reason the ""Contacts ... Manage Groups" works correctly, is it is running my custom search which includes logic to populate the group contact cache. ( ie  CRM_Contact_BAO_GroupContactCache::load ).

Unfortunatly, this issue means that the end-user cannot use the "Schedule/Send Mass Email" action from the custom search results, as that creates a hidden smart group behind the scenes. 
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Custom Search that includes smart group data, odd behavior
May 28, 2013, 12:07:26 pm
is the new Smart Group that is being created definitely set to be a Mailing List?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Custom Search that includes smart group data, odd behavior
May 29, 2013, 02:36:12 pm
I figured out and fixed my issue. It had nothing to do with allowing the user to filter on smart groups.

I had a "group by " in my sql.    This is what I added to my code to fix the issue:

if ( $onlyIDs ) {

   $groupby = "";
}else{
   $groupby = "GROUP BY contact_a.id ";

}


 $sql = "SELECT $select
      FROM  $from
      WHERE $where
      ".$groupby;
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Custom Search that includes smart group data, odd behavior
March 03, 2014, 03:36:31 am
I'm getting exactly the same behaviour in a custom search extension I am writing. Searching by group membership is an option in this search. Currently, if the user leaves the option at 'all groups' or chooses to select by membership of a standard group, the results are correct, but if the user chooses to select by membership of a smart group the search returns zero results, even in cases where we know there should be results.

Could someone please clarify what the 'group by' issue is? Why is a 'group by' problematic in searches which use smart groups as one of the search criteria? The search I have built uses a 'group by' clause to ensure that participants with multiple activities on the same activity type only show up once in the search results.

Thanks.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom Search that includes smart group data, odd behavior

This forum was archived on 2017-11-26.