0

Where (which JIRA issue, if any) did this change in API behaviour come from, and was it documented/expected?

The same Contact,get API call returns different results between 4.6 and 4.7.

IMO the new style is better, but I'm not sure the change was intended/documented. (I want clarification so I can expect the new behaviour to stick!)

I've confirmed this behaviour today by testing on the 4.6 (Joomla) and 4.7 (Drupal) demo sites.

API call for Contact,get with return=group shows groups in the results.

civicrm_api3('Contact', 'get', array(
  'sequential' => 1,
  'return' => "group",
  'id' => 3,
));

In 4.6 the result has groups shown by their group "title" (not name). Since group titles may contain a comma, there is some lack of certainty in the results (leading to workarounds like this).

[
  'is_error' => 0,
  'version' => 3,
  'count' => 1,
  'id' => 3,
  'values' => [
    [
      'contact_id' => '3',
      'groups' => 'Example group,Example smart group',
      'id' => '3',
    ]
  ]
]

In 4.7 the result has groups shown by their group ID, which is a bit more predictable to work with.

[
  'is_error' => 0,
  'version' => 3,
  'count' => 1,
  'id' => 3,
  'values' => [
    [
      'contact_id' => '3',
      'groups' => '4,7',
      'id' => '3',
    ]
  ]
]

I've checked the CiviCRM API Changelog and enquired on chat.civicrm.org without any luck so far. Help me, SE!

1

1 Answer 1

1

This is not an answer to your question, but were I to post it as a comment the whole thing would be on one line/unreadable. It seems to me that the most desirable format is:

[
  'is_error' => 0,
  'version' => 3,
  'count' => 1,
  'id' => 3,
  'values' => [
    [
      'contact_id' => '3',
      'groups' => array(4, 7),
      'id' => '3',
    ]
  ]
]

... or even:

[
  'is_error' => 0,
  'version' => 3,
  'count' => 1,
  'id' => 3,
  'values' => [
    [
      'contact_id' => '3',
      'groups' => array('Example group', 'Example smart group'),
      'group_ids' => array(4, 7),
      'id' => '3',
    ]
  ]
]
1
  • I do like that idea. Structure is good. Commented Sep 28, 2016 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.