What would be the best way of batch Smart Group creation using Relationships data, where Organisation name, taken from Individual Relationship data, should become a Smart Group title and all Individuals, who are in Relationship to the Organisation should become the group members. We've some issues doing this manually due to a large amount of Organisations we have in a database.

There is a similar question asked here Can I create a Smart Group programatically? , which sounds like a half of an answer; it requires pretty high level of civicrm internal logic involvement though. Any chance to get same information in "explain like im five" style, if there are no API methods to crack this?


  • I'd probably start by looking at how existing smart groups (maybe ones with pretty simple criteria) are stored in the database, but that would indeed significantly involve the internal logic. – DaveFF Oct 29 '15 at 20:01
  • Well, in theory(c) it might be possible to manually insert copies of saved searches in a database ( not sure about how to generate qfKey though ) and than use saved search ID for Group creation via API, but it most likely won't work. – yurg Oct 30 '15 at 20:57
  • Possible duplicate of Can I create a Smart Group programatically? – michaelmcandrew Jun 20 '18 at 8:14
  • Hey there, actually this is the same question. It's just that you didn't get the answer you wanted :) Hence I am voting to close as a duplicate. Also, I added an answer explaining how (in 2018) you can do this via the API. – michaelmcandrew Jun 20 '18 at 8:16
  • @michaelmcandrew Thank you for API solution; the post is quite dated so I'm not sure what was an initial purpose or idea behind the question, yet it seems the second paragraph says something like " no API"; perhaps it was about CiviCRM GUI experience instead of CiviCRM API. Anyway, thank you for the clarification useful for future references! – yurg Jun 21 '18 at 9:48

Your Answer

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

Browse other questions tagged or ask your own question.