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) »
  • select values in civicrm_contact_add()
Pages: [1]

Author Topic: select values in civicrm_contact_add()  (Read 1153 times)

kathykelley

  • Guest
select values in civicrm_contact_add()
December 10, 2008, 07:31:51 pm
I am new to civicrm and was planning to use the API.  Should I be doing this?  My client has a lot of custom fields and I want to assign values to them when I create contacts.  I have some fields that are of type "select" and I cannot for the life of me get the value to take effect in the database.  I figured out multiple select by creating an array.  Any help with this would be greatly 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: select values in civicrm_contact_add()
December 11, 2008, 04:25:01 am
This example might  help: http://fisheye.civicrm.org/browse/CiviCRM/trunk/tests/api/v2/ContactAddWithCustomData.test?r=15610

Kurund
Found this reply helpful? Support CiviCRM

kathykelley

  • Guest
Re: select values in civicrm_contact_add()
December 11, 2008, 07:14:18 am
The code doesn't really help.  All I want to know is how I set things up to assign a custom field a value that happens to be defined as type select.  Do you know what I do?  I know that in the case of multiple selelcts I created an array.  Arrays don't seem to work for regular selects.

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: select values in civicrm_contact_add()
December 11, 2008, 07:40:10 am
Can you try passing following parameter to add function:

Quote
array( 'first_name' => 'Demo',
          'last_name'  =>  'User',
          'custom_x'   =>   2  )

where 'x' is id of the field and 2 is the value.

HTh

Kurund
Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • select values in civicrm_contact_add()

This forum was archived on 2017-11-26.