Solved

SharePoint 2010 - Search or Filter Document Sets

Posted on 2014-04-24
8
1,364 Views
Last Modified: 2014-04-30
I have a document library configured to use Document Sets. Additionally I created a metadata term set and the managed metadata column for the purpose of adding that column to the documents that are within the document set. I have enabled Metadata Navigation and Filtering and enabled that for the document library. Everything works fine, including the filtering.

When I use the filter, I am presented with the document sets that meet the criteria, and when I go in to a document set, I see the documents. What I need to do is go a step further and enable the capability to filter or search within the document set.

Any suggestions or help in getting this to work would be greatly appreciated.
0
Comment
Question by:SneekCo
  • 4
  • 4
8 Comments
 
LVL 31

Accepted Solution

by:
Jamie McAllister MVP earned 500 total points
Comment Utility
To define a specific path you want search result for you need to provide a 'u' querystring parameter to the search results webpart which specifies that path.

I put together some javascript to look at the url within my Document Set. When you're in the Document Set there's an argument in the url called 'RootFolder'. This includes the Document Set name and an ugly representation of the path.

I extract this on a button click (normal HTML button with some javascript) and forward the page on to Search results page, specifying the Document Set path as my 'u' querystring parameter.

To get this functionality into your Document Set Homepage, go into Doc Set Settings and edit homepage. Insert a Content Editor Web Part into the page and add your script/html for the custom search in there.

My main function that does the work is here;

function customSearch(inputId) {

	var origUrl = window.location.href;
	var searchUrl = '';
	
	try
	{
	if (origUrl.indexOf("&k=") != -1)
	{
		searchUrl = origUrl.split('&k=')[0];
	}
	else
	{
		searchUrl = origUrl;
	}
	}
	catch (err)
	{
		searchUrl = origUrl;
	}
	
	var searchTerm = "&k=" + document.getElementById(inputId).value;
var baseURL = "http://MyDomain";

var rootFolder = getParam("RootFolder");

var decoded = urldecode(rootFolder);

var uri = baseURL + decoded;

var encoded = encodeURIComponent(uri)

	var listParams = "&u=" + encoded;
	window.location.href = searchUrl + searchTerm + listParams;
}

Open in new window


I also took this a step further and added a Search Results Web part to actually display the search results within the Doc Set Homepage, but that was somewhat more complicated...
0
 
LVL 14

Author Comment

by:SneekCo
Comment Utility
Thanks, this is very helpful and I understand the approach. This part I am somewhat unsure of:

forward the page on to Search results page, specifying the Document Set path as my 'u' querystring parameter.

Would it be possible for you to include the entire code including the html part?

Many Thanks
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
Comment Utility
This line will do the redirect;

window.location.href = searchUrl + searchTerm + listParams;

Open in new window


In my case I actually redirected to the same page I was on (The Doc Set Home). I added a Search Results Webpart above the Doc Set Contents web Part, which is invisible unless Search has been called.

Then I got my hands on some XSL that changed the search results to look like my Doc Set default View.

That XSL is here;

http://sharepoint2010search.codeplex.com/
0
 
LVL 14

Author Comment

by:SneekCo
Comment Utility
I have all code added, two extras functions and the results web part on the document set welcome page. All is working fine, but I am getting no results :-(

Any idea what I might be missing. Note: when I am at the document library level and use the metadata filter I am able to filter out all except for what I query. Just at the document set level I get no results at all.

Many thanks
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 31

Expert Comment

by:Jamie McAllister MVP
Comment Utility
What does the url of the page look like when there's no results?  Can you post it here?
0
 
LVL 14

Author Comment

by:SneekCo
Comment Utility
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
Comment Utility
Immediate difference I can see is that your 'u' parameter is not url encoded and mine is.

replace the 'https://' in your 'u' param to 'https%3A%2F%2F' (and the rest of that param).
0
 
LVL 14

Author Comment

by:SneekCo
Comment Utility
Thanks for the info. Giving it a go and will post when it is up and running.
0

Featured Post

Integrate social media with email signatures

Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

Join & Write a Comment

Suggested Solutions

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now