It’s a common requirement to be able to do wildcard free text searches on SharePoint lists.
Whilst you can’t do wildcard or complex Boolean search (that’s what the search system is for) you can get close with a contains search. Thus searching for “Acme” will return “ACME Construction” and “Big ACME Rentals” but not “Rent-A-Crane”
It’s not easy though, and does require SharePoint Designer and a Filter Provider such as our FilterPoint product.
Filter Providers and Filter Consumers.
In SharePoint you have
- Filter Providers (like FilterPoint or SharePoint Enterprises own filter web parts)
- Filter Consumers (like the List View web part or other web parts such as our PivotPoint).
The Filter Provider sends the filter you’ve entered (e.g. “Customer” and “Acme”) but it’s entirely up to the Filter Consumer what it does with that filter.
This means that if you want to do things like Date Ranges, wildcard filtering using “Contains” operations you have to set those options on the Filter Consumer.
Our products (PivotPoint, Planner etc) have options to allow you to easily set what to do with the incoming filters, but SharePoints built in List View web part does not.
Using “Contains” filters to do free text search in FilterPoint.
We’re going to use SharePoint Designer to setup Parameters and Filters in the List View Web Part (LVWP) so we can do wildcard type filtering.
(It’s a limitation of SharePoint that you can’t do this without SharePoint Designer – sorry!)
First go to the web part page that has your list (or create a new, empty web part page and add your list to it).
In our example we’ve got a list of Customers with the customer name in the Title field.
- Open this page in SharePoint Designers edit view.
(Depending on what type of page this is will invoice different steps – see these tips for more help on using SharePoint Designer or the online manual for SharePoint Designer)
- Once in the edit view, click anywhere List, then click on the Parameters icon on the Ribbon (under Options)
- If you’re using SharePoint Designer 2013 you will have to select the List View web part differently as the design view has been removed – follow the instructions and then continue
- In the Data View Parameters window :-
- Click New Parameter,
- In the Name box put Customer_Search.
- (You can use whatever name you want here but it needs to be consistent across the next few steps, also note an underscore, no spaces!)
- Change Parameter Source to Form
- Change Form Field to Customer_Search
- Click OK
- Now select Filter from the Ribbon (top left of the edit page view) to open the Filter Criteria window
- Choose
- The field name you want to filter on – in our case the customers’ names are in the Title field.
- Set the Comparison operator to Contains (this means that searching for ACME will return “ACME Corporation “or “Big ACME rentals” etc.)
- Set Value to be the parameter we created above – Customer_Search.
- Click OK
We’re done with SharePoint Designer (SPD) now so you can hit save and close SPD.
Open the page you’ve been working with in the browser – notice that the list won’t be displaying any results as we’re not passing in anything to our Contains Parameter.
Edit the page and add the Filter Point web part (or another FilterProvider web part of your choosing)
- Select the Web Part menu (button on top right highlighted) and then Connections > Provide Filter To > Customers (or whatever your list is called.
- On the next dialog box select Get Parameters From and then Finish
- Right – we’ve added a Parameter and a Contains Filter to the List view and connected the FitlerPoint web part to the List View, nearly there!
- Next open FilterPoint’s configuration toolpane
- Select New and enter a label such as Customer
- Set the Filter Style to “Free Text”
- Set the Field Name to From the connected web part and choose the parameter that you set above – in our case Customer_Search.
- Click OK and you’re finally done.
(For more info on configuring FilterPoint see the manual)
Searching for “acme” or “rent” will now return any customer that has that string in their name :-
A couple of points to note :-
- You can’t do complex searches like “acme AND rent” or “Rent*Crane” – just Contains or Begins With searches.
- If you want to setup additional filters then once you’ve connected the web parts in “Get Parameters” mode (rather than the normal “Get Filter Values” mode) you will have to repeat the above steps to create Parameters and Filters in the List for each filter. It’s a pain but a limitation of SharePoint.
- If you do add additional Parameters and Filters be sure to set the And/Or operator correctly – for most use cases you will want And.
#