Solved

SharePoint 2010 - Search or Filter Document Sets

Posted on 2014-04-24
8
1,411 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 31

Accepted Solution

by:
Jamie McAllister MVP earned 500 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 16

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 31

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 16

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 31

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 16

Author Comment

by:Walter Curtis
ID: 40028206
0
 
LVL 31

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 16

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Preface There are many applications where some computing systems need have their system clocks running synchronized within a small margin and eventually need to be in sync with the global time. There are different solutions for this, i.e. the W3…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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