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 Drupal Modules (Moderator: Donald Lobo) »
  • Views relationships possibly not working for contributions
Pages: [1]

Author Topic: Views relationships possibly not working for contributions  (Read 1093 times)

andersiversen

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Views relationships possibly not working for contributions
September 29, 2013, 02:26:11 pm
Hi

I have a view displaying civicrm contact fields. I also need to have a field in the same view displaying a field from the contribution records. I've tried making a views relationship and chosen "CiviCRM Contacts: Contribution Records" the description text for this relationship says "The numeric ID of the Contact".
I cannot get it to display anything from contributions - the field always turns out empty. And then I get the same error message as this guy, when a field using the relationship is in the view:
http://forum.civicrm.org/index.php?action=post;topic=29768.0;last_msg=127502
Do I somehow need to feed the contact_id to the contribution relationship, and if so, how do I do that? Or is it maybe a bug (like this: http://forum.civicrm.org/index.php?topic=25444.0 )
Though I would guess, since it's a view with civicrm contact fields, the views relationship should get the id automagically.

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: Views relationships possibly not working for contributions
September 29, 2013, 02:32:10 pm

FYI, the views integration code is still looking for a maintainer :(

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

andersiversen

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: Views relationships possibly not working for contributions
October 07, 2013, 07:42:03 am
Ok - I don't feel confident enough, yet, to be a maintainer myself :)
But I've tried making a simple test view: It's a civicrm_contact view with a views relationship for contributions. The views shows the contact id and the contribution id. This simple view clearly shows what the error is: the contact id is matched to the contribution id instead of to the contact_id in the contributions table. I guess the error can be found somewhere in civicrm/drupal/modules/views - I've tried to look, but I'm unable to find it.

andersiversen

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: Views relationships possibly not working for contributions
October 07, 2013, 08:04:04 am
Aaaand I think I found it!!

In civicrm/drupal/modules/views/components/civicrm.contribute.inc line 41-46:

Code: [Select]
  $data['civicrm_contribution']['table']['base'] = array(
    // Governs the whole mozilla
    'field' => 'id',
    'title' => t('CiviCRM Contributions'),
    'help' => t("View displays CiviCRM Contributions, with relation to contacts."),
  );

'field' => 'id' should be 'field' => 'contact_id' instead. Can anyone verify that? I'll make an issue if this truely is the bug according to some of you forum gods :)



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: Views relationships possibly not working for contributions
October 07, 2013, 08:32:20 am

we are working hard at the manchester sprint on some of the views issues (thx to dave carpenter for taking the lead on this)

i just tested it out on 4.4 and things seemed to be fine, here's the mysql query views generates:

Code: [Select]
SELECT civicrm_contribution.id AS id, civicrm_contact.display_name AS civicrm_contact_display_name, civicrm_contact.id AS civicrm_contact_id, civicrm_contribution.total_amount AS civicrm_contribution_total_amount
FROM  `crm_44`.civicrm_contribution civicrm_contribution
LEFT JOIN `crm_44`.civicrm_contact civicrm_contact ON civicrm_contribution.contact_id = civicrm_contact.id
LIMIT 10 OFFSET 0

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

andersiversen

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: Views relationships possibly not working for contributions
October 08, 2013, 10:00:25 am
Good to know the issues are being worked on, and that this particular issue is fixed in 4.4 !

In 4.3 though, this is how my query looks:
Code: [Select]
SELECT civicrm_contact.id AS id, civicrm_contribution_civicrm_contact.id AS civicrm_contribution_civicrm_contact_id
FROM
{civicrm_contact} civicrm_contact
LEFT JOIN {civicrm_contribution} civicrm_contribution_civicrm_contact ON civicrm_contact.id = civicrm_contribution_civicrm_contact.id
Which is wrong.
I've attached an export of my view.

Changing "id" to "contact_id" in civicrm.contribute.inc fixes this, though I guess it's probably somewhere else that id is confused with contact_id, but I cannot figure out where...

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: Views relationships possibly not working for contributions
October 09, 2013, 01:27:53 am

r u on the latest version of views?

i dont think changing the 'id' to contact_id is the right thing to do and might have other implications

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

andersiversen

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: Views relationships possibly not working for contributions
October 09, 2013, 03:37:13 am
Yes I'm on views 7.x-3.7.
And I'm also pretty sure that my fix isn't the right one...

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Views relationships possibly not working for contributions

This forum was archived on 2017-11-26.