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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Related contact search (searching through relationships)
Pages: [1]

Author Topic: Related contact search (searching through relationships)  (Read 1212 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Related contact search (searching through relationships)
February 16, 2011, 07:00:51 am
Hello folks,

A lot of clients over the years have asked me for related contact search, and it looks like a common request on these forums also.

e.g. "show me all parents of children that played football last year"

We would like to start work on this soon.  Have written a wiki page that describes how we think we will approach it.  We are really open to people here telling us better ways in which we could implement this and also contributing financially to make it happen.  Let me know your thoughts.

http://wiki.civicrm.org/confluence/display/CRMDOC33/Related+contact+search+%28searching+through+relationships%29

Thanks,
Michael
« Last Edit: February 16, 2011, 07:18:28 am by michaelmcandrew »
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Related contact search (searching through relationships)
February 16, 2011, 03:30:06 pm
Have somebody that would be interested and can contribute something towards it. Uses would be like:

  • Show me all the individuals who have a relationship with any member of a specified set of contacts, where set of contacts might be something like contacts that have a given tag (but might be more general)
  • Show me all the people who work at an organization whose primary address is in _insert_city_
  • Show me all the people who were at a meeting with someone from organization_name this year (i.e., their relationship is not recorded as a relationship, but comes from having both been involved in a common activity)

The last one could be out of scope.

The first one you could probably replace "set of contacts" with "contact or group", because you could always do a regular search of some kind to create the group, then "Show me all the contacts with a relationship with any member of _group_name_".

andrewhunt

  • I post occasionally
  • **
  • Posts: 80
  • Karma: 13
    • AGH Strategies
  • CiviCRM version: all of 'em
  • CMS version: Drupal, Joomla, and WordPress
Re: Related contact search (searching through relationships)
February 16, 2011, 06:08:49 pm
I've also encountered many requests along these lines.  I think the ideal would be an extension of the Advanced Search where you could use various criteria to find contacts and then turn around and make it instead return contacts with the relationship X of contacts with those criteria.  SQL-wise, it would be a search of civicrm_relationship for contact_id_a where contact_id_b is in the select query of those criteria (or vice-versa, depending upon the direction of the relationship).  There's also the funky situation of sibling-like relationships where the contact could be either A or B.  Some clients have mistakenly understood the relationship fields of the Advanced Search to work like that.

Another idea, if various issues might make that too difficult, would be to have "find relations of these contacts" be a task available from the drop-down at the top of the search.  A user could select the relationship, and the query would just use the IDs available from the search results.  It may have the added benefit of narrowing to selected contact only.
You can find me at AGH Strategies.
Need help now?  Civi911 is your go-to for CiviCRM support.

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Related contact search (searching through relationships)
February 17, 2011, 09:00:56 am
I have written a custom search that I call "the adult child relationship search" . I will attach it to the wiki page.  It allows a person ( typically a teacher or the education director) to pull up all the parents of the kids in grade x.   The only filter is the group that that the kid is in.

It only looks for the "parent of" relationship. I am planning to enhance it to allow it to grab parents and stepparents in the same results. ( Or even any authorized relationship, as some kids are raised by their grandparent or other legal guardian)

It may be a useful starting point to improve on. 
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

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: Related contact search (searching through relationships)
February 17, 2011, 07:42:01 pm

1. Creating a task to find the relationship between the set of contacts found should be fairly easy. The main drawback would be you can perform additional tasks from the results screens, which seems to be the primary purpose of doing this

2. Creating a custom search seems relatively easy and is probably the next step forward (for the short term)

3. Avoid the creation of a custom group to find the related contacts would be a good thing (and avoid group proliferation)

Would be good if we can figure out how to apply a "filter" on search results and give the "related" contacts in a seamless manner. I'll think a wee bit about it

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

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Related contact search (searching through relationships)
February 23, 2011, 06:48:43 am
Hey there,

Glad that there is a lot of interest in this topic - it is contact RELATION management after all :)

"Creating a custom search seems relatively easy and is probably the next step forward"

I think that the seperation makes this possibly the easiest to understand conceptually: you seperate out the three objects:

* "All organisations with the major donor tag" 
* "All finance directors"
* "all employees"

The fact that you do this before hand means you don't have to remember where you are in the process.

Compared with the task workflow "find related contacts" that might get confusing or have too many steps to remember, e.g. 'Hang on a minute, where was I again?  Did I select the right group in the first place?'

The essence of the task workflow it seems is:
*carry out an advanced searched
*select the find related contacts task
*choose a relationship
*carry out another advanced search
*select the task you want to carry out

You could potentially see that as a five step wizard / concertina.

I take your point about group profileration, but maybe that is a seperate issue that needs addressing somewhere else.  I see a lot of organisations which have loads of groups already in there CiviCRM.  That could be to do with group visibility - are all groups always visible - should we organise groups a bit better than just alphabetically.  But that is another question :)
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Related contact search (searching through relationships)
February 23, 2011, 09:23:52 am
Hey there,

Lobo said "two phases, the first one being super cheap and quick:

* do it as a custom search

* figure out how to add a "filter" / "transformer" to advanced search to do the needful. This way its all in one screen

The first one is 3-5 hours. The second one should be approx 45-47 hours. I suspect we'll iterate over a few solutions before we settle down on one that works nicely"

Lobo also said "i do think having a filter / transformer / query rewriter would help extend search a lot"

I'm interested to hear more about what a filter / transformer / query rewriter would look like.  I'm wondering if it has anything to do with the recently implemented being able to return memberships, activities etc. from advanced searches.  Or is it a mechanism to 'pipe' searches?
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

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: Related contact search (searching through relationships)
February 23, 2011, 09:30:19 am

i think the goal is to reduce the number of steps, and in general there are lots of use cases that we cant think of. I basically think would be nice to allow search queries to be modified via a hook. Two simple types would be:

* filter - which restricts the search to a smaller set

* transformer - which basically takes a "set of contacts" and returns "a different set" based on some criteria

i do think both of them can be accomplished via a hook. In our current case, the "transformer" would also need what "relationship" type to return, so:

gimme all the "parents" of kids who are in group A and have custom values B and C. So the transformer needs another "search" element, i.e. relationship type to be useful. I suspect there will be other transformers also

i'll see what i can come up with if i'm awake on the plane ride

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Related contact search (searching through relationships)

This forum was archived on 2017-11-26.