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 (Moderator: Dave Greenberg) »
  • problems with crm_[get|update|create]_contact
Pages: [1]

Author Topic: problems with crm_[get|update|create]_contact  (Read 1754 times)

SteveM

  • I post occasionally
  • **
  • Posts: 47
  • Karma: 3
    • OpenConcept Consulting, Inc.
problems with crm_[get|update|create]_contact
July 11, 2007, 10:06:35 am
I am getting errors because crm_get_contact() doesn't find a contact, but crm_create_contact() discovers that it exists and throws an error.

Using CiviCRM version 1.7.9379 (Drupal 5.1, PHP 5.1.6); the code:


$get_contact = crm_get_contact( $crm_params );
if ( get_class( $get_contact ) == 'CRM_Contact_BAO_Contact' ) {
   $contact = crm_update_contact($get_contact, $crm_contact);
} else {
   $contact = crm_create_contact($crm_contact, 'Organization');
}


These are the variable values for one such error:

Used for crm_get_contact():
$crm_params = array(3) { ["contact_type"]=>  string(12) "Organization" ["organization_name"]=>  string(20) "Dark City Coffee Co." ["email"]=>  string(26) "raymond@darkcitycoffee.com" }

Used for crm_create_contact():
$crm_contact = array(5) { ["external_identifier"]=> string(4) "1139" ["organization_name"]=> string(20) "Dark City Coffee Co." ["email"]=> string(26) "raymond@darkcitycoffee.com" ["home_URL"]=> string(29) "http://www.darkcitycoffee.com" ["custom_42"]=> string(7) "Coffee " }

Is there a problem with crm_get_contact()? Do I need to resort to using the Search APIs?
« Last Edit: July 11, 2007, 01:54:25 pm by SteveM »

SteveM

  • I post occasionally
  • **
  • Posts: 47
  • Karma: 3
    • OpenConcept Consulting, Inc.
Re: problems with crm_[get|update|create]_contact
July 12, 2007, 07:57:44 am
And the same thing happens when I change the if statement to use crm_contact_search_count():

( crm_contact_search_count($crm_params) > 0 )

... returns false, inaccurately, for that same contact.

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: problems with crm_[get|update|create]_contact
July 12, 2007, 09:06:51 am

Steve:

Sorry for the delayed response, a few things:

1. Can u remove the 'email' parameter from get_contact / search_contact and see if that works. (i suspect it will!)

2. If so, can u file an issue against 1.8

3. If not, can u get on IRC :)

thanx

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) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • problems with crm_[get|update|create]_contact

This forum was archived on 2017-11-26.