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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Bidirectional address sharing?
Pages: [1]

Author Topic: Bidirectional address sharing?  (Read 476 times)

kenahoo

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.3.16
Bidirectional address sharing?
April 19, 2011, 08:41:54 pm
Hi,

The person who's doing a lot of the work on our contact database has made use of the Address Sharing functionality by having Person A share Person B's address, and also Person B share Person A's address.  This does seem to work, but the "data loop" makes me uneasy - is it kosher?  She likes it because she can see on both records that the address is shared.

 -Ken

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Bidirectional address sharing?
April 20, 2011, 05:32:55 pm
Hmm - I was a bit surprised to see that this "works". In the database, you get 2 address records - each pointing to the other as the "master". I played around a bit (export, edit ...) and the only weird behavior I saw was mailing labels. If you don't say "merge same addresses" - the 2nd contacts label is missing their name for some reason.

I would spend a bit more time if I were you testing outputs that you use to make sure no problems pop-up, but seems ok from what i played with.
Protect your investment in CiviCRM by  becoming a Member!

kenahoo

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.3.16
Re: Bidirectional address sharing?
April 20, 2011, 07:37:26 pm
Thanks Dave.  I'm actually a little squeamish about keeping it that way - for one thing, it means that neither person's address can be edited until it's un-shared, which is weird.

I'm going to search for records that have this setup and convert them to unidirectional sharing.  Looks like something like the following SQL can find them:

Code: [Select]
SELECT a.id, b.id, a.contact_id, b.contact_id, b.street_address, a.master_id, b.master_id
FROM civicrm_address a
JOIN civicrm_address b ON a.street_address=b.street_address
JOIN civicrm_contact c ON a.contact_id=c.id
JOIN civicrm_contact d ON b.contact_id=d.id
WHERE a.contact_id<b.contact_id
AND a.is_primary=1 AND b.is_primary=1
AND c.is_deleted!=1 AND d.is_deleted!=1
AND a.master_id=b.id AND b.master_id=a.id
ORDER BY b.street_address;

 -Ken

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Bidirectional address sharing?
April 21, 2011, 12:47:15 pm
yeah - not editable is a good point.

You could look at developing and submitting a patch that displays address sharing info on the "master address" block in the contact summary. I suspect others might have the same need as your user to see this upfront. We already do this in the edit form - so should be pretty easy. Need to think about how much info is needed (i.e. if you're looking at an employer contact record and there's lots of individuals sharing that address, we don't want to list them). Easiest would be to just show that address is shared and perhaps a count (which is what is shown on edit form).
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Bidirectional address sharing?

This forum was archived on 2017-11-26.