Is there a way in which I can easily see how the smart groups are related (as in include / exclude search)?

When I try to build a group which selects the contacts I need, I often combine multiple smart groups to arrive to necessary results. It would be very convenient to see how they are related. Is there an easy way to tell, if a particular group is used in some other group (so that it could be modified or deleted without worry)? Or should I check all other groups to make sure that none of them actually uses the group I am about to delete/modify?

1 Answer 1


Smartgroup criteria are stored using the SavedSearch api. Use the API explorer (/civicrm/api#explorer) and select entity: SavedSearch action: get

In each of the values returned, there is a form_values key with a list of components that define the search. The list varies depending on how the search was created.

If you look at one created from an include/exclude search, then it contains components like:


Without checking the details of each of those parameters, it's very likely that group_id 4 is involved in this query.

Likewise for an example created from Advanced Search:

                "IN": [

So group_id 5 is involved in this.

A smart group is linked to a SavedSearch by the saved_search_id attribute - in API Explorer, set entity to Group, action to get and look for saved_search_id

If you just want to understand which groups depend on others, then visual inspection of the SavedSearch.get output might be enough.

Expanding this into an extension to show those dependencies would be nice, but tricky since the components of the form_values list depends on how the search was created. You would need to experiment with the various ways of creating smart groups to identify all the syntaxes that relate to groups but even then, custom searches define their own definitions (as include/exclude does), so it would be easy to miss some giving incomplete results. In other words, it would be easier to say "This group does depend on this other group" rather then "This group does not depend on this other group".

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.