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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Custom search and Smart Group error
Pages: [1]

Author Topic: Custom search and Smart Group error  (Read 485 times)

civi5

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 3
  • CiviCRM version: 4.1
  • CMS version: Drupal 7
  • MySQL version: MySQL 5
  • PHP version: 5.3.6
Custom search and Smart Group error
July 02, 2014, 03:52:31 pm
I made a custom search and am trying to use it to create a smart group.  The custom search works and returns all the fields that I need.  Everything on the search end seems to be correct.

However when I choose the action to make a smart group I get the following error:

[debug_info] => INSERT IGNORE INTO civicrm_group_contact_cache (contact_id, group_id)
        SELECT DISTINCT contact_id, group_id FROM civicrm_temp_group_contact_cache353
       [nativecode=1054 ** Unknown column 'group_id' in 'field list']

The smart group does get created but I also get the same error whenever I click on the groups tab on any contact until the smart group is disable.

I did create the contactIds() function and it only returns the IDs of the users that selected.  It seems the groupContactCache.php is the culprit somehow.  On line 491 where it creates the Temporary table the selectSQL string is only search for the contactID and it creates a temp table with just contact IDs but there is not association with the group ID.  Should my contactIDs function in the custom search also return a group id somehow? 

Also if I go to manage groups and click on the contacts link for the smart group it will list all the users as expected.  It will give the same error, however, if I try to delete the smart group without disabling it first.

I have user the included custom searches and made smart groups and everything works as expected.  So there is a disconnect between my new custom search and what the smart group cache is expecting to see.  Any insight or hints on this one?

By the way I am running on the almost latest 4.4.5 version of Civi.... new update just came out.
 

krypto

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 5
  • IT guy for @bhahumanists. Running Civi on WP.
    • British Humanist Association
  • CiviCRM version: 4.5.8
  • CMS version: WordPress 4.x
  • MySQL version: 5.5.x
  • PHP version: 5.5.x
Re: Custom search and Smart Group error
July 04, 2014, 05:08:50 am
Can't be any specific help, but whenever I've had this error I've just copied anything if statements relating to $onlyIDs and empty($contactIDs) out of a custom search that works, and that's fixed it.

civi5

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 3
  • CiviCRM version: 4.1
  • CMS version: Drupal 7
  • MySQL version: MySQL 5
  • PHP version: 5.3.6
Re: Custom search and Smart Group error
July 07, 2014, 08:14:53 am
Thanks for the lead.  I copied everything from a custom search and still was throwing the error.

I did end up getting it straightened out after printing all the SQL queries that were being generated as I debugged.

What I ended up doing was adding the group_id to the select under the if(justIDs) section changing it from
$select = "contact_a.id as contact_id";
 into
$select = "contact_a.id as contact_id, 187 as group_id";

The 187 was the next to be assigned group number.  The last current group is 186.  Obviously this is a dirty hack that will only work for that specific group instance and if you create a new group from the same search then it will all fall apart.  So far though it seems to be working as expected.

I am not sure why the temporary table create SQL never created a group_id until I specifically selected it on the custom search. In GroupContactCache.php are all the SQL routines that I was debugging but I could not find out why it chose only the contact_id and not the group_id. 

Not really a fix but a hack anyway to get it working.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Custom search and Smart Group error

This forum was archived on 2017-11-26.