1

How would it be possible to hook into civi's searches to always lookup a custom field when searching for name?

Background: In our setup we handle big departments as distinct contacts. Their name is the base organization name and we provide a custom field "Additional name" in which the department's name is stored.

Example:

Contact A: Base Organization named "University of Bielefeld",
Contact B: Department of A named "University of Bielefeld" with
           additional name "Faculty of Physics"
Contact C: Department of A named "University of Bielefeld" with
           additional name "FooBar Institute"

We do this for different reasons, for instance because pdf letter addressing is simpler.

Problem: If our users head over to search box, advanced search or simple search and fill the name or name/email field with "foobar", they don't get correct results.

Any ideas?

  • 1
    Are you part of the Bielefeld conspiracy? the answer is simple: there is no university there, it has no department, and that city doesn't exist ;) – Xavier Jan 20 '16 at 14:44
1

I can't think of a way to easily alter the search in all cases (quick search, autocomplete, normal search...

What we usually do when we have to store organisational units is to create a new contact type (department) and store together the org+"|"+dep as the organisation name.

if this is a matter of making it easier to input the departments in that format or tweak some reports, you can still keep a separate field for the department and alter the organisation name via the hook, or split the organisation name on the "|" to separate the university from the department.

From a data modelling point of view, it won't win any beauty contest, but does the job. and it's more or less what's happening with the individuals, where first and last names are separate columns that are concatenated into the sort_name and display_name.

  • What is the new contact type for? How do you make use of it? – nielo Jan 21 '16 at 9:02
  • the new contact type would be a subtype of "organisation" and to make it clearer for everyone (user or custom code if needed) that the format of the organisation name is "special". – Xavier Jan 21 '16 at 9:06

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.