?
Solved

SharePoint 2010 - Search or Filter Document Sets

Posted on 2014-04-24
8
Medium Priority
?
1,575 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:Walter Curtis
  • 4
  • 4
8 Comments
 
LVL 32

Accepted Solution

by:
Jamie McAllister MVP earned 2000 total points
ID: 40022007
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 20

Author Comment

by:Walter Curtis
ID: 40023544
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 32

Expert Comment

by:Jamie McAllister MVP
ID: 40024429
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 20

Author Comment

by:Walter Curtis
ID: 40028092
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
 
LVL 32

Expert Comment

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

Expert Comment

by:Jamie McAllister MVP
ID: 40028939
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 20

Author Comment

by:Walter Curtis
ID: 40031973
Thanks for the info. Giving it a go and will post when it is up and running.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
Determining the an SCCM package name from the Package ID
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

831 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