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 »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Not getting custom fields through contact api
Pages: [1]

Author Topic: Not getting custom fields through contact api  (Read 1353 times)

jyotigupta

  • Guest
Not getting custom fields through contact api
August 30, 2010, 06:49:33 am
I upgraded my civicrm from 3.0.2 to 3.2.2, but im still not getting custom data fields using contact API in module.

civicrm_initialize(TRUE);
require_once "api/v2/Contact.php";
$params = array('id'   => 15547,
         'return.custom_6'   => 1,
                  );
$contacts = civicrm_contact_search( $params );

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Not getting custom fields through contact api
August 30, 2010, 05:33:01 pm
Hey contact_search is deprecated - try contact_get
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

jyotigupta

  • Guest
Re: Not getting custom fields through contact api
August 30, 2010, 10:08:12 pm
I tried civicrm_contact_get( $params ); but its not working.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Not getting custom fields through contact api
August 30, 2010, 10:09:18 pm
That's a bit vague...
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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Not getting custom fields through contact api
August 30, 2010, 10:33:47 pm
I use another function to retrieve custom data, CRM_Core_BAO_CustomValueTable::getValues. The contact_get should work, but I had problems as well. It needs a thorough check-up, which I have planned for the end of this month. Try this?

Code: [Select]
$civipar = array(
                 "entityID" =>  $retrieved['contact_id'],
                 "custom_4" =>  1,
                 "custom_5" =>  1,
                 "custom_6" =>  1,
                 "custom_7" =>  1);
             $civires = CRM_Core_BAO_CustomValueTable::getValues($civipar);
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

jyotigupta

  • Guest
Re: Not getting custom fields through contact api
August 30, 2010, 10:46:15 pm
Yes.. its working. Thanks a lot

jyotigupta

  • Guest
Re: Not getting custom fields through contact api
August 31, 2010, 02:13:42 am
Hey! now i want to update the organization custom data in a module... but its inserting a new row in custom table instead of updating..

$params = array('entityID'      => $eid,
         'custom_6'       => $helpline_no,
         'custom_9'       => $helpline_name,
         'custom_10'      => $sel_provider_list,
         'custom_12'      => $sel_rated_list
      );
$contact = CRM_Core_BAO_CustomValueTable::setValues($params);

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: Not getting custom fields through contact api
August 31, 2010, 07:54:02 am

if i had to guess, $eid does not exist in the table and/or the custom group is  a multi-record custom group

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

jyotigupta

  • Guest
Re: Not getting custom fields through contact api
August 31, 2010, 10:44:08 pm
$eid is exists in custom value table & custom group is not a multi-record custom group.

I went through the code in file CRM/Core/CustomValueTable.php, setValues() function calls self::create( $cvParams )

In my case, in create() function 'id' is not exists in $field array, so it is inserting the new record.

 if ( array_key_exists( 'id', $field ) ) {
   $sqlOP = "UPDATE $tableName ";
   $where = " WHERE  id = %{$count}";
   $params[$count] = array( $field['id'], 'Integer' );
   $count++;
   $hookOP = 'edit';
 } else {
   $sqlOP = "INSERT INTO $tableName ";
   $where = null;
   $hookOP    = 'create';
 }

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Not getting custom fields through contact api

This forum was archived on 2017-11-26.