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' not working for CiviCRM Activities
Pages: [1]

Author Topic: Views 'Relationships' not working for CiviCRM Activities  (Read 1802 times)

Barnacle

  • I post occasionally
  • **
  • Posts: 62
  • Karma: 2
    • White Fuse Media
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.x
  • PHP version: 5.3
Views 'Relationships' not working for CiviCRM Activities
July 24, 2012, 07:03:28 am
I created a view of Activities. I want the logged in user to see only activities of which they're the target.

In the "Relationships" options I added "CiviCRM Activity Targets: Target Contact ID." But none of the fields that this makes visible have anything in them.

I've looked in the civicrm_activity_target database and there is data which should be showing. But I can't access the actual target contact ID to use it as a contextual filter.

Is there something I'm doing wrong or is this a bug? I'm so tantalisingly close to making this happen I can't believe it's not possible!
--
http://whitefusemedia.com/

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' not working for CiviCRM Activities
July 24, 2012, 10:33:28 am

I suspect you are hitting the limits of the views integration. However extending and letting views know more about the schema is not too hard. You can take a look at the code here: drupal/modules/views/

If you do improve it, please file an issue and attach your patch

thanx

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

CatorgHans

  • I post frequently
  • ***
  • Posts: 157
  • Karma: 5
  • CiviCRM version: 4.4
  • CMS version: drupal
Re: Views 'Relationships' not working for CiviCRM Activities
September 22, 2012, 02:47:03 pm
Targets and Assignees both don't work.

If I look at the SQL the views creates I see the error.

In an assignee view there is this line:
Code: [Select]
LEFT JOIN civicrm_contact civicrm_contact_civicrm_activity_assignment ON civicrm_activity_assignment.id = civicrm_contact_civicrm_activity_assignment.id
but it should be
Code: [Select]
LEFT JOIN civicrm_contact civicrm_contact_civicrm_activity_assignment ON civicrm_activity_assignment.assignee_contact_id = civicrm_contact_civicrm_activity_assignment.id
In an target view there is
Code: [Select]
LEFT JOIN civicrm_contact civicrm_contact_civicrm_activity_target ON civicrm_activity_target.id = civicrm_contact_civicrm_activity_target.id
and it should be
Code: [Select]
LEFT JOIN civicrm_contact civicrm_contact_civicrm_activity_target ON civicrm_activity_target.target_contact_id = civicrm_contact_civicrm_activity_target.id
in civicrm.views.inc I see
Code: [Select]
  $data['civicrm_activity_assignment']['assignee_contact_id'] = array(
    'title' => t('Assignee Contact ID'),
    'help' => t('The contact who is assigned the activity.'),
    'relationship' => array(
      'base' => 'civicrm_contact',
      'field' => 'id',
      'handler' => 'views_handler_relationship',
      'label' => t('CiviCRM Assignee Contact ID'),
    ),
  );

and

Code: [Select]
  $data['civicrm_activity_target']['target_contact_id'] = array(
    'title' => t('Target Contact ID'),
    'help' => t('The contact who is the activity\'s target.'),
    'relationship' => array(
      'base' => 'civicrm_contact',
      'field' => 'id',
      'handler' => 'views_handler_relationship',
      'label' => t('CiviCRM Target Contact ID'),
    ),
  );
which looks proper to me, but I don't know exactly where and how the SQL is created.
Does this help one of the developers?
« Last Edit: September 22, 2012, 02:56:11 pm by CatorgHans »

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' not working for CiviCRM Activities
September 22, 2012, 03:03:19 pm

can u try this and see if it works:

Code: [Select]

  $data['civicrm_activity_assignment']['assignee_contact_id'] = array(
    'title' => t('Assignee Contact ID'),
    'help' => t('The contact who is assigned the activity.'),
    'relationship' => array(
      'base' => 'civicrm_contact',
      'left_field' => 'id',
      'field' => 'assignee_contact_id',
      'handler' => 'views_handler_relationship',
      'label' => t('CiviCRM Assignee Contact ID'),
    ),
  );

contributions also had a similar issue which i fixed a few mins back :)

let me know if this fixes it and i'll commit it for 4.2.2

if i had to guess a recent views upgrade either fixed or tweaked the protocol and hence the breakage

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

CatorgHans

  • I post frequently
  • ***
  • Posts: 157
  • Karma: 5
  • CiviCRM version: 4.4
  • CMS version: drupal
Re: Views 'Relationships' not working for CiviCRM Activities
September 22, 2012, 03:15:59 pm
Ah, I have this problem in 4.1.6 (with views 3.0 for drupal 6)
There this solution does not work.

(I emptied the views cache to be sure)


CatorgHans

  • I post frequently
  • ***
  • Posts: 157
  • Karma: 5
  • CiviCRM version: 4.4
  • CMS version: drupal
Re: Views 'Relationships' not working for CiviCRM Activities
September 22, 2012, 03:22:50 pm
It does work after I deleted ALL cache!

If possible also change in the 4.1 branche, I will have a few sites that keep on drupal6 for a while.

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

This forum was archived on 2017-11-26.