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

API custom_field_get() returns a list of custom fields, rather than an actual custom field

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.1
    • Fix Version/s: 3.4.2
    • Component/s: CiviCRM API
    • Labels:
      None

      Description

      Under v3 of the API, custom_field_get does not actually return a custom field, rather an array of all custom fields.

      May I propose that this be amended, so that custom_field_get returns a single custom_field, and custom_fields_get returns the list (current behaviour).

      I am currently relying on the below as a workaround.

      function civicrm_api3_custom_field_retrieve($params)
      {
      try

      { _civicrm_api3_initialize(true ); civicrm_api3_verify_mandatory($params); require_once 'CRM/Core/BAO/CustomField.php'; $customfieldBAO = new CRM_Core_BAO_CustomField(); $default = array(); $result = $customfieldBAO->retrieve($params, $default); return civicrm_api3_create_success($result,$params,$customfieldBAO) ; }

      catch (PEAR_Exception $e)

      { return civicrm_api3_create_error( $e->getMessage() ); } catch (Exception $e) { return civicrm_api3_create_error( $e->getMessage() ); }

      }

      Similarly, there is no _get function for CustomGroup. Is this deliberate?

        Attachments

          Activity

            People

            • Assignee:
              eileen Eileen McNaughton
              Reporter:
              tomgillett Tom Gillett
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: