2

I occasionally have a list of contacts outside of Civi but with CiviIDs that I want to search for in Civi, but aren't grouped in any easily accessible way (no common event, activity, tag, group, etc. to search for). If it were a longer list, I'd do an update import on the contacts (with no actual changes) adding them to a new temporary group. But if I have fewer than say 10, that seems like a lot of steps.

I thought, "A regex search builder would work." But when I put

\b(64|5917|5725|5892|5852|5818|5893|5850)\b

OR

\b64\b

OR even

[64]

into the regex search, I get a "Please enter a valid value" error. I seem to get a valid search when using only numeric text ("64") without any regex operators, which kind of defeats the entire purpose of regex.

I'm not a big regex user, so I could believe I've screwed up the regex. Anything I'm doing wrong here?

  • Depending on how big your list is, you could just import the IDs, and add to New Group as part of the import, then click on Group and you have your search output. – petednz - fuzion May 11 '18 at 19:22
4

Adding to the Suggestion of Jon G there is a simple extension to SearchBuilder that allows to paste ContactIDs into a separate field and converts those to an 'IN' query with comma separated values: https://github.com/bhahumanists/bha.searchbuilder

  • Thanks to JonG for the background and a simple solution. I'm choosing this as my answer because it avoids the step of concatenating the list with comma deliminators. – Phil Morice Brubaker May 14 '18 at 15:12
7

It's true - looking at the code, I can see that Search Builder expects an integer if you're searching on an integer field. An exception is made for using the IN operator, in which case it validates each value separately.

Trying to validate a regex to ensure it's non-malicious is a very difficult task, and I think the appropriate answer is to remove the regex function from the Search Builder on integers. Work is being done on Civi 5.2 to remove operators from Search Builder that aren't appropriate.

However, to solve YOUR problem, you should use IN, separating your values by commas like so: 64,5917,5725,5892,5852,5818,5893,5850

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.