1

I get regular requests to turn an external list of contact IDs into a Civi group. I don't have a nice way of doing this atm.

Search Builder

The best approach I have so far is with Search Builder, of all things. I have a little bit of javascript that adds an input and then turns that into a search builder search. This sends the data via POST to the usual search results screen, where you can save it to a group in the normal way. You can do this with tens of thousands of IDs.

enter image description here

But Search Builder is going away, and it'd be nice to do it in a nice Form Builder screen that doesn't need refreshing.

Search Kit / Form Builder

Search Kit can't quite do it. You can't paste in a comma-separated list of IDs:

enter image description here

(you can paste in comma-separated lists for other fields, just not when it's not a lookup field like Contact ID)

I thought about making a custom quickform that links to a Search with the values in the URL - but this hits limits of the max length of URLs. And we regularly have tens of thousands of people.

Any other ideas? Is there any way to send data to Search Kit in the POST?

2 Answers 2

3

Can you do import with update flag and on preview screen you can add contacts to group.

enter image description here

or using URL you can do /civicrm/task/add-to-group?reset=1&cids=119,122,137

2
  • That'd work, yep. I'd like something for regular users without import permissions, though. Also it just feels like overkill for what is basically a simple contact ID lookup. Jan 18 at 17:49
  • 1
    You can do /civicrm/task/add-to-group?reset=1&cids=119,122,137 Jan 18 at 18:02
1

I see in your comment you're looking for something in the UI, but posting this anyway since might be useful.

Assuming your csv only has one column:

cv ev '$fp = fopen("mycsv.csv", "r"); while (($id = fgets($fp)) !== FALSE) { civicrm_api3("GroupContact", "create", ["contact_id" => trim($id), "group_id" => 4]); } fclose($fp);'

Replace "4" with the group id.

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.