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) »
  • Using Views to show employee list
Pages: [1]

Author Topic: Using Views to show employee list  (Read 844 times)

mikem

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 4.4.3
  • CMS version: 7.X
Using Views to show employee list
December 06, 2013, 08:07:08 am
I am trying to create a view that will show a user a list of the employees in that persons organization.

I can get the name of the organization with the persons name but i cannot get the relationship to work correctly so that it only shows employees of the individuals organization.

Any thoughts? - i saw an older post but it was from 2009 and was outdated...

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: Using Views to show employee list
December 06, 2013, 05:12:00 pm
hey mike - i need to get this written up as a blog so will use this as a test ground - pls let me know if the explanation and/or example View I post shortly help you.

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: Using Views to show employee list
December 06, 2013, 05:55:34 pm
Views needed a makeover in terms of handling Relationships so that we could join to a relationship from either end (ie Contact A or Contact B)

The old Views Relationships are still available but are called 'deprecated'

NB: Where I refer below to Contact A and Contact B - these are the 'ends' of the Civi Relationship Types (so go check who/what is at which end if you are not sure)

The new approach requires an extra step now when building a View using Views Relationships (VR) to access Civi Relationships (CR)

Basically for every Relationship you want to use to connect to other contacts you need to create 2 x VRs

The first VR needs to be of the type
Quote
CiviCRM Contacts: CiviCRM Relationship (starting from contact A)
Connects a contact (as contact A) to a relationship.

The second will use the above VR to attach to the other contact (eg Contact B)
Quote
CiviCRM Relationships: Contact ID B
The contact B

Below are some examples and a View is attached to get you started. It can be helpful to rename these Relationships as you create them to help keep the logic clear.

Children and their Parents

This is quite simple as we are presuming that Contact A is the child and you just need to grab the Parent who is Contact B so there is one Civi Relationship involved, and hence two VRs required

- add Display Name to Fields (and Label it Child)
- create a VR to connect A to the required relationship Child/Parent
- utilise the relationships above when creating the next VR to get hold of Contact B (the Parent)
- use this VR on Display Name2 to make is show the Parent's name


Employees of my Employer

This is a bit more complex (or maybe I just haven't spotted a shortcut), as we are starting with Contact A (me) - then grabbing Contact B (my employer) - then grabbing Contact A again (my employer's employees)

The steps required in summary
- create a VR to Connect A (who we will later filter to the 'current user' to relationship (Employee/Employer)
- utilise the relationships above on a second VR to get hold of Contact B (the Employer)
- use this VR on Display Name1 to show the Employer
- create the next VR to connect B to the relationship Employee/Employer
- utilise the above to get (back to) the Employees
- use this on Display Name2 to show all the Employees of (my) Employer

then since we only want to show Employees of the Employer of the current user, there is one more VR to make use of

Quote
CiviCRM Contacts: Drupal ID
Relates a CiviCRM Contact to the Druapl User Record

- create another VR to connect the Civi Contact to the Drupal User

and then use this to make a Filter for the View to restrict the contact to the logged in user

(can achieve similar using Contextual Filters but thought I would demo this without)


Parents (and School) of Children who are signed up to an event

This also has another step involved since in this case we are starting with a View build off Civi Participants rather than Civi Contacts - so there is a new first step: connect the Participant to the Contact.

  • Connect A (the Participant) to their Civi Contact
  • connect the Civi Contact above to the required relationship Child/Parent
  • connect the relationship above to the Parent (Contact B)
  • repeat 2 and 3 using a different CiviRelationship to connect the Child to the School
« Last Edit: December 06, 2013, 05:57:35 pm by petednz »
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) »
  • Using Views to show employee list

This forum was archived on 2017-11-26.