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) »
  • Unknown column contact_a.id in field list adding contacts to group
Pages: [1]

Author Topic: Unknown column contact_a.id in field list adding contacts to group  (Read 1755 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
Unknown column contact_a.id in field list adding contacts to group
May 20, 2013, 02:16:15 pm
I was trying to run a custom search specifically, Contributions made in Year X and not Year Y.  I generated results and in the result page I clicked the radio button for All XX records.  I chose to add the records to a group and then I get the following error.

"1054 ** Unknown column 'contact_a.id' in 'field list'"

This also happens on the demo site using the same process.  I found the resulting SQL to be

SELECT contact_a.id as contact_id FROM civicrm_contact AS contact LEFT JOIN civicrm_contribution contrib_1 ON contrib_1.contact_id = contact.id LEFT JOIN XG_CustomSearch_SYBNT xg ON xg.contact_id = contact.id WHERE contrib_1.contact_id = contact.id AND contrib_1.is_test = 0 AND contrib_1.receive_date >= 20130505000000 AND contrib_1.receive_date <= 20130511000000 AND xg.contact_id IS NULL GROUP BY contact.id ORDER BY donation_amount desc

The problem is neither civicrm_contact nor civicrm_contribution have a "contact_a". I think you just need to chagne contact_a to simple be contact so that is is contact.id as contact_id.   I am just not sure where the SQL for this particular search is generated.  If anyone has any pointers that would be helpful. 

I got the SQl above from the following file
CRM\Contact\Selector\Custom.php



Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Unknown column contact_a.id in field list adding contacts to group
May 20, 2013, 02:40:00 pm

Not all custom searches integrate nicely with the actions box. specifically custom searches that are not on contacts dont behave very well

we'll need to update / improve the protocol to allow such things to co-exist in a better manner

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

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: Unknown column contact_a.id in field list adding contacts to group
May 21, 2013, 06:16:37 am
Hmm I will file a bug tracker report just to make it official.

For now what I did is I just hacked the SQL manually to get to function... simple str_replace.  It worked but its certainly not production quality and its limited to just the specific search at hand.  Once I used the action I reverted the code back to the original. 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Unknown column contact_a.id in field list adding contacts to group

This forum was archived on 2017-11-26.