0

I have a child groups C and B, each with 20 different contacts in them. Both child groups are in parent group A. I need to find all contacts in all children of A since C and B might be removed later or new children added to A. But A will not change. However, Group A is not itself populated. As a result, the CiviCRM API returns 0 results. Is there handy API method which will help me out?

API Command:

 $result = civicrm_api3('GroupContact', 'get', array(
  'sequential' => 1,
  'group_id' => "Donors_74",
));

Actual results from the API explorer:

{
"is_error": 0,
"version": 3,
"count": 0,
"values": [

    ]
}

Expected result: 1676

enter image description here

We are using CiviCRM 4.7.25.

  • What API command are you running that is returning 0 results? – Aidan Oct 20 '17 at 15:09
  • I have updated my question with the API command – DMCoding Oct 20 '17 at 15:17
0

You can use the 'group' filter on the Contact api to get members of parent groups.

$result = civicrm_api3('Contact', 'get', array(
  'sequential' => 1,
  'group' => XX,
  'options' => array('limit' => 0),
));

where XX is the id of the parent group (A).

  • Unfortunately, that causes the error Uncaught CiviCRM_API3_Exception: [no such field: DB Error: no such field. – DMCoding Oct 20 '17 at 17:50
  • Are you using the id or the name? It's working for me with the numeric id, but the name produces an error. – Aidan Oct 20 '17 at 23:12
0

The query worked fine for me, i am using name of group instead of id. Example:

$result = civicrm_api3('Contact', 'get', array(
  'sequential' => 1,
  'group' => "Advisory Board",
  'options' => array('limit' => 0),
));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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