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) »
  • How do I link an individual to a household in the API?
Pages: [1]

Author Topic: How do I link an individual to a household in the API?  (Read 3083 times)

twowheeler

  • I post occasionally
  • **
  • Posts: 115
  • Karma: 11
    • Harrisburg Christian Performing Arts Center
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.1
  • PHP version: 5.3
How do I link an individual to a household in the API?
February 28, 2008, 03:44:50 am
If I add/edit an individual contact, I can select "Use household address" and then choose to create a new household or link to an existing household.  How do I do that in the API?  Any suggestions appreciated.


Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How do I link an individual to a household in the API?
February 28, 2008, 05:31:09 am
Currently you cannot do this using api. You will have to manually first create household, then create Individual and then add address to it.

kurund
Found this reply helpful? Support CiviCRM

twowheeler

  • I post occasionally
  • **
  • Posts: 115
  • Karma: 11
    • Harrisburg Christian Performing Arts Center
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.1
  • PHP version: 5.3
Re: How do I link an individual to a household in the API?
February 28, 2008, 05:16:40 pm
Ok thanks, but I'm not sure what that means.  I can create the household and create the individual, no problem.  Is adding the address to the individual just a matter of writing the household_id into the mail_to_household_id field in civicrm_individual?  Do I have to create a relationship?


Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How do I link an individual to a household in the API?
February 28, 2008, 05:42:43 pm
Quote
Is adding the address to the individual just a matter of writing the household_id into the mail_to_household_id field in civicrm_individual?
Yes, that's the first step. Then you need to create new location for Individual with same details as in Household location.

Quote
Do I have to create a relationship?
Yes

You might want to check following functions in CRM/Contact/Form/Individual.php
createSharedHousehold()
handleSharedRelation();
copyHouseholdAddress();

HTH

kurund
Found this reply helpful? Support CiviCRM

twowheeler

  • I post occasionally
  • **
  • Posts: 115
  • Karma: 11
    • Harrisburg Christian Performing Arts Center
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.1
  • PHP version: 5.3
Re: How do I link an individual to a household in the API?
February 28, 2008, 05:57:53 pm
Eeek.  I'll give it a go.

twowheeler

  • I post occasionally
  • **
  • Posts: 115
  • Karma: 11
    • Harrisburg Christian Performing Arts Center
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.1
  • PHP version: 5.3
Re: How do I link an individual to a household in the API?
March 04, 2008, 04:53:33 am
Well, I'm part of the way there.  I can create a new household with
Code: [Select]
CRM_Contact_Form_Individual::createSharedHousehold( $params );and then create the relationships with
Code: [Select]
CRM_Contact_Form_Individual::handleSharedRelation( $pid, $params );
I am setting these variables,
Code: [Select]
$params['mail_to_household_id'] = $hhold_id;
$params['use_household_address'] = 1;
$params['contact_type'] = 'Household';
$params['create_household'] = $family. " Household";  // like "Jones Household"
I also figured out that I have to fill out an array like $params['location']['1']['address']
to hold the street address variables.

Yet I can't get it to actually link the household address to the individual record.
The 'use_household_address' should be doing that.  The command, 
Code: [Select]
CRM_Contact_Form_Individual::copyHouseholdAddress( $params );doesn't seem to actually do anything.  It does not return any errors either.

So obviously I am missing something.  I'd be grateful for any additional pointers.
Thanks guys!


Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How do I link an individual to a household in the API?
March 05, 2008, 02:56:49 am
Can you check "mail_to_household_id" field for Individual record in civicrm_contact. It should have Household id that you created.

HTH

kurund
Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How do I link an individual to a household in the API?

This forum was archived on 2017-11-26.