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

Custom Fields no longer get properly returned (4.5.4) when requested through the API

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Won't Fix
    • Affects Version/s: 4.5.4
    • Fix Version/s: None
    • Component/s: CiviCRM API
    • Labels:
    • Documentation Required?:
      None

      Description

      When I create a query like this:
      /sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&json={"sequential":1,"return":"custom_4","options":{"limit":25}}&api_key=yoursitekey&key=yourkey

      I get the proper value for custom_4 in my contact

      "contact_id": "25",
      "contact_is_deleted": "0",
      "civicrm_value_soft_credits_2_id": "6",
      "custom_4": "17",
      "id": "25"

      However when I do this:
      /sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&json={"sequential":1,"return":"custom_4,nick_name","options":{"limit":25}}&api_key=yoursitekey&key=yourkey

      "contact_id": "25",
      "nick_name": "<DELETED>",
      "contact_is_deleted": "0",
      "civicrm_value_soft_credits_2_id": "",
      "custom_4": "",
      "id": "25"

      This is the query:
      SELECT contact_a.id as contact_id, contact_a.is_deleted as `contact_is_deleted`, contact_a.nick_name as `nick_name`, civicrm_value_soft_credits_2.id as civicrm_value_soft_credits_2_id, civicrm_value_soft_credits_2.rbucks_4 as custom_4 FROM civicrm_contact contact_a
      LEFT JOIN civicrm_value_soft_credits_2 ON civicrm_value_soft_credits_2.entity_id = `contact_a`.id WHERE ( contact_a.is_deleted = '0' ) AND ( 1 ) AND ( 1 ) GROUP BY contact_a.id LIMIT 0, 25

      Which when I run it manually does return NULL's for all the custom values

      I think the problem sits in the "GROUP BY contact_a.id". When I either do GROUP BY contact_a.id, contact_a.nick_name" or "ORDER BY contact_a.id", it returns correctly. I think the problem is using a GROUP BY statement to order a result, however trudging through the code, I could not get heads or tails on the entire Contact/BAO/Query.php file.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              guruevi Evi Vanoost
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: