Searches and actions
This chapter covers different ways to find information you've stored in CiviCRM. Two of the techniques in this chapter - finding contacts and the "search-action" work flow - are core functions in CiviCRM, so most if not all users will find this chapter helpful.
We will start off with some simple searches and then move on to more advanced techniques. CiviCRM beginners should be familiar with Quick search, Advanced search and the component searches. More advanced users should also look at reports, custom searches and search builder.
There are three main reasons to search:
- Finding a specific contact: the Quick search box can find contacts by name or email address, and an Advanced search can find contacts by other characteristics.
- Performing an action on a contact that meets certain criteria: a common workflow in CiviCRM, called a "search-action", is to find contacts that meet certain criteria and then perform an action on them. For example, you might want to find all contacts in the advisory group in order to invite them to a meeting, find all those whose memberships have recently expired to send a renewal reminder, or find all contacts aged under 25 in a specific location to send them an email about an upcoming event nearby.
- As a form of ad-hoc reporting.
For reports, searching is often useful but has limitations. For example, you can't group results by particular criteria, or summarise or easily produce graphs of the results. For more advanced reporting, read about CiviReport in the section Reporting.
Note that when you search for character strings, the search is not case-sensitive. For example, if you search for 'brooklyn', the search will return strings with capitalised letters if the string exists, e.g. 'Brooklyn' or 'BROOKLYN'.
Quick search for contacts
The easiest way to find a specific contact, if you know part of their name or email address, is to use the Quick search box that appears in the navigation menu at the top left of the screen. Contacts that match the phrase you enter will appear in a dropdown list below the box. For example, entering "peter" will find
- people who's first or last name is Peter
- people who have Peter appearing as part of their name, e.g. Mary Peterson
- people who have Peter as part of their email address, e.g. firstname.lastname@example.org
- organisations with Peter in their name, e.g. Petersfield Community Centre.
You don't need to type the full name of the person - just the first few letters. The following screenshot shows that two contacts turn up in our database when we search just for "pe".
Advanced search allows you to search across all the information you have about your contacts. For example, you could find "all contacts in Venezuela" or "all advisory group members". If you specify two or more categories of information, the search displays every contact that matches all the categories. For instance, you can combine the two criteria just mentioned to find "all advisory group members in Venezuela".
The Advanced search screen is accessible from the navigation menu Search > Find Contacts > Advanced Search. On this screen, search criteria are grouped into sections which refer to different types of data that you can search on, such as address data, notes and information from components such as Contributions or Events. Each group of criteria is shown as a gray bar. If you click on a gray bar, it expands to reveal the options within that group. For example, if you want to search for all people in your database from 16 to 18 years old, click on the Demographics bar. It expands, as shown in the following figure, and you can specify the birth date range you are interested in.
Combining search criteria
Different criteria are combined by "ANDing" them. For example, if you select the tag "major donor" and the country "Mexico", the search will return major donors from Mexico.
Within criteria groups that allow you to check boxes for more than one value, these options are also combined by "ANDing". For example, if you can search for contacts whose Preferred Communication Method is both Email AND SMS.
With fields that allow you to select values from a drop down list, options are combined by "ORing". For example, you could find contacts that live in Mexico OR the United States by selecting both countries in the country field.
Display Advanced Search results as ...
Advanced Search returns your results as Contact records by default. However, you may want to get another record type instead. For example, you may want to see all the Contribution records which match your search criteria (while taking advantage of the rich set of search filters available in Advanced Search). Simply select the record type you want from the dropdown in the upper right corner of the Advanced Search form.
Modifying search columns
Advanced searches allow you to use to change the columns displayed in your search results. The default columns are Name, Street Address, City, State, Postal Code, Country, Email and Phone. If you want to display a different set of columns (perhaps to include a custom field or remove a column you don't need), create a Profile with the Search Results option selected. Make sure that the fields in this Profile are set to "Public User Pages and Listings" visibility, and are marked as Results Columns. (For more information about creating Profiles, which are described in detail in the Profiles chapter in the Configuration section.)
The Profile will appear in the Search Views dropdown menu in the upper right corner of the form, as shown below. The following screenshot shows what the menu displays after someone has created a Profile called "Birthday".
Combining this feature with the "Batch Update via Profile" action provides a powerful method of viewing and updating a specific set of fields across a batch of contact records.
Instant view pop-up
You can see a pop-up box with detailed information for any contact listed in your search results by hovering over the contact icon in the left column, as shown below. You can adjust the fields shown in this "pop-up view" by modifying the fields included in the "Summary Overlay" profile (Administer > Customize > CiviCRM Profile).
The "search-action" workflow
After you retrieve your search results, you can perform a number of actions. An Actions box appears above the results. You can select either all records or specific records, then carry out an action with the selected records. Different actions are covered in more detail in the chapter on Everyday Tasks.
Some of the most commonly used actions are Add Contacts to Group, Export Contacts, Map Contacts, and creating and printing Mailing Labels. (To use Map Contacts, you will need to configure Mapping and Geocoding. You can read more about this in the Installation chapter of the Configuration section of this manual).
For example, to send email to a selected number of contacts, mark the contacts you are interested in and then select Send Email to Contacts in the dropdown list of actions.
The wildcard (%)
Understanding wildcards greatly expands your search options. A wildcard represents "any character" (letter, numeral or punctuation mark). In CiviCRM, the wildcard is represented by the % symbol (you may be familiar with other symbols such as * from other applications). It is most easily understood through examples.
Suppose that somebody asked you to find a contact with a first name similar to "Michael", but possible something different such as "Michelle" or "Michał". If you search for "Mich%" you will find all these variations, including a contact who is supposed to be named "Michael" but whose name was misspelled as "Micheal". Wildcards can be used before, after, or even within words. For example, searching on 'Mich%el' will exclude "Michał" and "Micheal" but still find "Michelle" and "Michael".
This search is not case sensitive. Entering "mi%el" in lowercase will also find contacts with an upper case 'M' in their name.
Most CiviCRM components offer a search on the data they maintain, such as Find contributions, Find members, etc. These forms work in a similar way to Advanced search but return rows of the main objects associated with the components, instead of contacts. Find Members returns memberships, Find Participants shows event registrations, Find Contributions returns contributions and so on.
Each component search has its own Action list. See the Component sections for more details.
Advanced search lets you choose from a wide range of criteria, but it has limitations. The main limitation is that the search criteria you enter into different fields are "ANDed" together.
The Search Builder tool provides an alternative for situations when you need to search using OR for some criteria. For example, you can build a search for contacts who are born within a range of dates OR who are female. To do this, access the Search Builder tool and Edit Search Criteria from the navigation menu: Search > Search Builder.
Search Builder is intended for advanced users and requires you to use specific formats for your search values. Refer to the online documentation at http://wiki.civicrm.org/confluence/display/CRMDOC/Search+Builder before you try to create your own searches.
Custom searches are designed to answer specific questions that can't be easily answered using Advanced search or Search Builder. A good example are the "Exclude Contacts" and "Exclude Groups" options, which, in combination with a previously run advanced search, allow you to find contacts that do not meet certain criteria.
Go to: Search > Custom Search in the navigation menu and look at the list of available custom searches. These customised searches have been written by members of the CiviCRM community to meet their own needs, and then contributed back to the community to share with others who need the same or similar custom searches. It's worth spending some time exploring these searches as some may be useful to you, and they will give you an idea of the sorts of things that are possible.
It is possible to write your own custom searches, but you'll need to be comfortable with MySQL and PHP. See the section of this manual called Extending CiviCRM for more information about how to do this. If you create a custom search that you think could be useful for others, consider contributing it back to the community.
By combining Include and Exclude options, you can find contacts who are in one group but not in another. You can find these options, which are shown in the following screenshot, in the navigation menu Search > Custom Searches.