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 and Relationships B - A
Pages: [1]

Author Topic: Views and Relationships B - A  (Read 3669 times)

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
Views and Relationships B - A
April 09, 2009, 10:11:24 pm
Can anyone shed a bit of light for me. Having my first look in to Views (using 3 since the common word is 2 will never made it to beta and is being superceded by 3 which is at alpha4 - if you cared)

Just curious if I am missing the v obvious. Starting with "items of type CiviCRM Contacts" and using 'relationships' I get the option for A-B which spits me out a lovely list, and when I filter by = Employee of I get just those contacts with 'employee of'.

But in "CiviCRM Relationships" there is "Relationship Type A-to-B. The Type of Relationship, i.e. Employee of, Household Head for..." but no equivalent B-to-A. Is that intentional, only thing possible, an oversight?

cheers
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

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 and Relationships B - A
April 10, 2009, 07:21:45 am

I suspect it was an oversite / not immediately applicable to the person (danilad?) who contributed the relationship code

i think adding it should not be too hard

Not sure i understand the views 2/3 statement. views2 is past beta

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

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: Views and Relationships B - A
April 10, 2009, 01:50:43 pm
How can anyone understand what I am talking about when I write that 'alpha' stuff about Views when of course that reference was to Panels.  ::)

Ok, will probably have to take a look at B - A, not sure which of us will pop on to IRC for some pointers.
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

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Views and Relationships B - A
April 11, 2009, 06:41:19 pm
Hi, peterd.

Could you please explain what do you want to achieve with views?

The field which you mention (Relationship Type A-to-B) was made in this way to remove duplicates, because

if Relationship Type A-to-B=='Employee of' then Relationship Type B-to-A=='Employer of'

And it's enough to select just one of them. Later you decide in 'fields' what you want to show (Contact A or Contact B information).

Please describe what you are doing & provide your view export (with a generic relationship so it's easy to replicate on any CiviCRM install).

Regards,
Danila

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Views and Relationships B - A
April 11, 2009, 09:38:00 pm
Views export will not help much in this situation, as Relationship custom fields table names depend on each setup... So just a description of what you whant to achieve will be enough.

Regards,
Danila

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: Views and Relationships B - A
April 16, 2009, 02:51:46 pm
ok - back to this - thanks for trying to clear this up for me.

Reason I would want B-A as well as A-B - because I might want to Group by b-A and have the B-A relationship name showing

In terms of
Quote
Later you decide in 'fields' what you want to show (Contact A or Contact B information).

I don't see where I find those options. Under fields I don't see where I can specify that I want Contact B v Contact A details to show. (Bit of a noob on this area mind you)

There are also some other fields that I think need to be exposed under Activities eg the option to display who it is assigned to (but realise this is not necessarily a single name)
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

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Views and Relationships B - A
April 18, 2009, 12:50:53 am
Hello, Peterd.

Try the following:

Go to Views administration page, add new view.
In View type, select "CiviCRM Relationships"
Get, for example, 'Relationship description' into fields
In 'relationships' tab of views interface add both Contact ID A and Contact ID B

Now go again to fields to add more information. For example, select 'CiviCRM Contact: Contact ID' and 'CiviCRM Contact: Display name'.

After this when you press 'add', there will be a drop-down allowing you to select

Relationship:
      - Contact ID A
      - Contact ID B

This way you can specify contact from which side of relationship should provide the data.

Regards,
Danila

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Views and Relationships B - A
April 18, 2009, 12:52:48 am
Please submit your question about CiviCRM Activities as a different topic - Activities use other piece of code as compared to CiviCRM Relationships.

Regards,
Danila

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: Views and Relationships B - A
April 18, 2009, 01:20:33 am
ho ho ho - that is so cool  ;D

how can this all be so easy!

big thanks
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

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: Views and Relationships B - A
April 18, 2009, 04:02:42 am
However, it still looks to me like Relationship B-A needs to be visible if I want to Group by that
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

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Views and Relationships B - A
April 18, 2009, 06:21:36 am
There are two ways to do this.

Proper way is to write something similar to civicrm_handler_field_relationship_type.inc or civicrm_handler_field_relationshipType.inc (or maybe both, don't remember currently why we need both of them) and to get 'name_b_a' from CRM_Core_PseudoConstant::relationshipType( );. Maybe it's possible to change those two files without creating new ones. After this a proper description of how to handle this info is to be added to civicrm.views.inc.

Faster way (in terms of implementing, probably. It will definitely cause longer SQL) is to add an additional 'join' to civicrm_relationship_type table (not sure of exact name) inside civicrm.views.inc here:

Code: [Select]
//TABLE JOINS FOR CIVICRM RELATIONSHIPS GO HERE!
 
    $data['civicrm_relationship']['table']['join'] = array(
                                                           // Directly links to contact table - link A
                                                           'civicrm_contact' => array(
                                                                                      'left_field' => 'id',
                                                                                      'field' => 'contact_id_a',
                                                                                      ),
                                                           // Directly links to contact table - link B also.
                                                           //    'civicrm_contact' => array(
                                                           //   'left_field' => 'id',
                                                           //   'field' => 'contact_id_b',
                                                           //   ),
                                                           );
 

and then describe additional fields later. You will need to use Views feature 'relationship' to link to CiviCRM Relationship type table and then get the data into fields specifying that the source of the data is Relationship type table.

Please submit your patch if you do this.

Regards,
Danila


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: Views and Relationships B - A
April 20, 2009, 04:19:17 am
many thanks - will add this to a long 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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Views and Relationships B - A

This forum was archived on 2017-11-26.