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 Import (Moderator: Yashodha Chaku) »
  • Import "uses household address"
Pages: [1] 2

Author Topic: Import "uses household address"  (Read 2637 times)

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
Import "uses household address"
July 24, 2009, 10:11:40 am
How can I import the fact that an individual ( which is part of a household) wants to use the household address.

Thanks,
Sarah
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: Import "uses household address"
July 24, 2009, 10:19:05 am

i dont think import supports the "uses household address" concept as yet.

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

avaguilar

  • I’m new here
  • *
  • Posts: 28
  • Karma: 1
Re: Import "uses household address"
July 20, 2010, 11:42:27 am
Oh... this needs to happen... we're already running into issues around this with groups and importing.   What is the best solution to set this up to use household addresses for lots of contacts?
alice

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: Import "uses household address"
July 20, 2010, 07:19:26 pm

I suspect we will need to tackle this when we do import restructuring and optimization. This is  a fairly large project. The import code today is fairly gnarly :(

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

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: Import "uses household address"
August 08, 2010, 03:41:12 pm
Is there an API that can be used to set the "Uses Household Address" flag to true, along with pointing to the correct household?  I am thinking of writing a batch script to take care of this issue.   Something along the lines of 

- Check of the contact is a member of a household.
- If previous check is true, then set "Uses Household Address" to true, along with pointing to the correct household.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Import "uses household address"
August 08, 2010, 03:52:14 pm
Sarah - I have fairly high on my agenda to see if I can do this using civimigrate so I'll let you know.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Import "uses household address"
August 08, 2010, 05:30:55 pm
Hi Sarah,

This was super-easy to build into my import. You need to set the $params['mail_to_household_id] to be the household id in the contact import and (unfortunately) you need to have an identical address record for both contact & household (Civi should manage updating them in sync from then on).

I just added this to my civimigrate import  - I had to write a couple of lines of code to generate the household name.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Import "uses household address"
August 09, 2010, 04:46:49 am
I am still trying to tackle this for contacts which were previously imported. ( Using the browser-based "Contacts-> Import Contacts" tool ). Any suggestions?

Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Import "uses household address"
August 09, 2010, 01:58:26 pm
no, I don't think the inbuilt method currently supports it. Do you have the household IDs?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Import "uses household address"
August 09, 2010, 06:38:43 pm
I can write a script that pulls the household id for each contact. The missing piece is how to update the individual contact record correctly.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Import "uses household address"
August 09, 2010, 06:50:20 pm
So - for the update you can pass into the civicrm_contact_create

$params['contact_id]= contactid
$params['mail_to_household_id] = householdid

If you already have an address for both you don't need to create one.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Import "uses household address"
September 02, 2010, 09:39:08 pm
My script correctly updates the "uses household address" flag , which I can verify when I check the individual in the GUI, however it does not display the household address in the "address" area of the individual. 

Here is my code:
$loc_params = array('version'    => '3.0',
                        'contact_id' => $hhid   
                        );
     
        $hhLocation =& civicrm_location_get($loc_params);
 
 print "<br> hh location id: <br>";
 
 $hh_loc_id = $hhLocation['address'][1]['id']; 

$params = array(
                    'contact_id'    => $cid,
                    'contact_type'    => 'Individual',
                    'location_id' =>  $hh_loc_id ,
                    'mail_to_household_id'      => $hhid);

    $contact =&civicrm_contact_update( $params );

-------------------------------

Note: both the individual contact and the household contact exist before I run my script.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Import "uses household address"
September 02, 2010, 09:48:47 pm
So, as of now Civi has an address for the individual & one for the household & you have to set up both and the flag as well.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Import "uses household address"
September 02, 2010, 10:25:13 pm
I updated my code  to retrieve the household location, then create a new location based on that. Then finally update the individual contact with the location id as part of  the param list. Still no luck:

print "<hr><br>contact id: $cid  household id:  hhid: $hhid  <br>";
 
 
 $loc_params = array('version'    => '3.0',
                        'contact_id' => $hhid   
                        );
     
        $hhLocation =& civicrm_location_get($loc_params);
        if( civicrm_error( $newLocation ) ) {
            echo 'Error occured while getting hh Location';
        } else {
            echo '<br>Got Location:';
            print_r( $hhLocation );
            echo "<br>";
        }
 
 
 //print "<br> hh location id: <br>";
 
 $tmp_address = $hhLocation['address'][1];
 echo "<br>tmp_address: ";
 print_r($tmp_address);
 
 $params = array('version'    => '3.0',
                        'contact_id' => $cid,
                        'address'    => $tmp_address
                        );
     
        $newLocation =& civicrm_location_add($params);
        if( civicrm_error( $newLocation ) ) {
            echo 'Error occured while creating Location';
        } else {
            echo '<br>Location Created:';
            print_r( $newLocation );
            echo "<br>";
        }
 
 $hh_loc_id = $hhLocation['address'][1]['id']; 
 //print "$hh_loc_id ";
 //print "<hr>";
 
 
 $params = array(
                    'contact_id'    => $cid,
                    'contact_type'    => 'Individual',
                    'location_id' =>  $hh_loc_id ,
                    'mail_to_household_id'      => $hhid);
    $contact =&civicrm_contact_update( $params );
    print_r($contact);
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

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: Import "uses household address"
September 04, 2010, 04:52:47 am
I got my code working.  Thanks for the help/suggestions.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Import "uses household address"

This forum was archived on 2017-11-26.