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

api.customvalue.get returns incorrect structure when passing an entity_table parameter

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6, 4.7
    • Fix Version/s: 4.7
    • Component/s: CiviCRM API
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      When fetching the custom value(s) of an entity and specifying the entity table , the retunr structure is incorrect, which makes it also difficult to loop over the result.

      Reproducable example on the demo site:

      // Set a custom value of participant 47
      $result = civicrm_api3('CustomValue', 'create', array(
        'entity_id' => 47,
        'custom_4' => "bean",
        'entity_table' => "civicrm_participant",
      ));
      
      // get all the custom values of participant 47
      $result = civicrm_api3('CustomValue', 'get', array(
        'sequential' => 1,
        'entity_id' => 47,
        'entity_table' => "civicrm_participant",
      ));
      

      current result :

      {
      	"is_error":0,
      	"version":3,
      	"count":2,
      	"values":[{
      		"entity_id":"47",
      		"latest":"bean",
      		"id":"4",
      		"0":"bean"
      	},
      	{
      		"entity_table":"Participant"
      	}]
      }
      

      expected result

      {
        "is_error":0,
        "version":3,
        "count":1,
        "values":[{
          "entity_id":"47",
          "latest":"bean",
          "id":"4",
          "0":"bean"
          "entity_table":"Participant"
        }]
      }
      

        Attachments

          Activity

            People

            • Assignee:
              mollux Mattias Michaux
              Reporter:
              mollux Mattias Michaux
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: