Solved

SharePoint 2010 - Search or Filter Document Sets

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

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

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 17

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 17

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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