Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-4007

API v2 is generally broken for multi-value custom fields

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2.0
    • Component/s: CiviCRM API
    • Labels:
      None

      Description

      Using civicrm_contact_search() you can retrieve a contact that looks like so:

      array (
      'contact_id' => '535',
      'contact_type' => 'Individual',
      'civicrm_value_attributes_3_id' => '527',
      'custom_2' => 'ushr_polling_committee',
      'custom_14' => 'M. Casey Grantee',
      )

      To add new values to custom_2 some scattered documentation indicates that you should give it an array of option labels
      However I attempted the following:

      array (
      'contact_id' => '535',
      'contact_type' => 'Individual',
      'civicrm_value_attributes_3_id' => '527',
      'custom_2' =>
      array (
      0 => 'USHR Polling Committee',
      1 => 'M. Casey Grantee',
      ),
      'custom_14' => '',
      )

      But the resulting database field ends up being:
      01

      I also attempted to pass the data as the null terminated string:

      array (
      'contact_id' => '535',
      'contact_type' => 'Individual',
      'civicrm_value_attributes_3_id' => '527',
      'custom_2' => 'ushr_polling_committeem_casey_grantee',
      'custom_14' => 'M. Casey Grantee',
      )

      But that left the database field blank. Equally odd results came from passing in an array of option values.

      No errors were thrown in any case.

      Not quite sure what is supposed to be happening here. In my mind civicrm_contact_search() should return multi-value custom fields as an array of option values, and conversely civicrm_contact_add() should accept the same.

        Attachments

          Activity

            People

            • Assignee:
              mover Michał Mach
              Reporter:
              dalin dave hansen-lange
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: