Document Sets were first introduced in SharePoint 2010 and are an excellent way to organize content. I've gained many enthusiastic users of Doc Sets, but there is one feature they often ask for - the ability to search inside a particular Document Set. The issue is that Document Sets can easily end up with tens or hundreds of documents in them, but the default search scope in SharePoint is usually going to search the whole site. With this in mind I devised a solution to allow my users to search just in the Document Set they're currently looking at.
Wouldn't it be nice to allow users to search inside the current Document Set like this? It just takes a few minutes to put this together! (I've documented here for SharePoint 2010, but this also works for 2013 and Office 365 with a minor tweak detailed below)
One very nice feature of Document Sets is that they have a 'Homepage' that you can edit. This allows you to change the look and feel, including adding extra web parts and through use of the Content Editor Web Part add Script. This thinking led me to my solution...
Search results webparts in SharePoint are driven by querystring parameters in the url of the page. I therefore realized that if I added a Core Search Results webpart to the Document Set homepage, and manipulated the URL with the users search term and the Document Set address then I could show Document Set specific Search results right there in the Document Set page.
The concept is illustrated below. I need to take the url of the Doc Set, and add two querystring parameters; k for the search term and u for the container I wanted to search. (This is Microsoft's naming convention, not mine!)
To achieve the above I first need to change the Doc Set Homepage for my library. Go to library settings and click the Document Set Content Type. (This is assuming you've already added that!)
In the next page click Document Set Settings
In that next page you'll see an option to edit the Doc Set Welcome Page.
Now you see the default template for the welcome page
This is what that same page looks like when you click edit. The various web part zones are visible;
Now we add a CEWP to the page as shown;
Next add a Search Core Results web part to the same web part zone;
Your page now looks like this;
Your users now see a Search box when they're viewing Document Sets. Entering a Search Term and clicking they see results from just that Document Set as below. This is better than before but the results are kind of ugly.
To change the look of the Search results to be friendlier, edit page again and go into the Search Core Results web part settings. Expand Display Properties, and click the XSL Editor button. (You may need to untick the 'Use Location Visualization' box to ungrey the button). In the editor that pops open, delete the text and paste in the contents of my SearchStyling.xsl file, also at the bottom of this article. Click OK and save your changes.
Your search results should now look fairly like a normal List View. Sorting and filtering is possible on the search columns, and the description field which is sometimes verbose can be expanded or not. The XSL I've provided can be tweaked to display different columns (there's a lot of properties in search results that aren't shown by default) including your own custom columns.
The files you need to make this work are below;
Subscribe to Cloud with a Sunny Outlook
Get the latest posts delivered right to your inbox