Body: <p>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. </p>
  
  <p>There is a similar question asked here <a href="https://civicrm.stackexchange.com/questions/3963/can-i-create-a-smart-group-programatically">Can I create a Smart Group programatically?</a> , 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? </p>
  
  <p>Thanks! </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-29T20:01:32.423Z
Comments.Text: 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.
Comments.UserDisplayName: DaveFF
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-30T20:57:17.420Z
Comments.Text: 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.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-20T08:14:54.127Z
Comments.Text: Possible duplicate of [Can I create a Smart Group programatically?](https://civicrm.stackexchange.com/questions/3963/can-i-create-a-smart-group-programatically)
Comments.UserDisplayName: michaelmcandrew
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-20T08:16:26.943Z
Comments.Text: 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.
Comments.UserDisplayName: michaelmcandrew
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-21T09:48:08.027Z
Comments.Text: @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!
Comments.UserDisplayName: yurg
Tags: <api><relationships><smartgroups>
Title: Smart Group create/alter via API
ThreadText: # Smart Group create/alter via API
  
  (Asked by: username_0 on 2015-10-29)
  
  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?](https://civicrm.stackexchange.com/questions/3963/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?
  
  Thanks!
  
  **Tags:** api, relationships, smartgroups
  
  > **Comments:**
  > **username_1**: 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.  
  > **username_0**: 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.  
  > **username_2**: Possible duplicate of [Can I create a Smart Group programatically?](https://civicrm.stackexchange.com/questions/3963/can-i-create-a-smart-group-programatically)  
  > **username_2**: 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.  
  > **username_0**: @username_2 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!  
  
  ---
  
  ## 0 answers
  
  