Quickly filter a List/Document Library View using URL
This one’s very useful when you’re having a lot of items in a list or document library and you need a quick filter.
If you’ll select the filter field it can happen that it will load for a long time. So lately I’m using URL. Suppose you have a long list of contacts and you need to find a contact named Boris.
In the AllItems.aspx – view of the page, add parameters
?FilterField1=[Field Name]&FilterValue1=[Value]
You can add more filterfield and filtervalue parameters to apply filters to more fields (FilterField2, FilterValue2, …)
The only trick is to know the Field Name like it’s saved in SharePoint. You can see this in the list settings page (click on a column name and check URL) or just make a manual filter for the first time.
In my case to find a contact with First Name Boris, I’d go to
http://[site_URL]/lists/contacts/AllItems.aspx?FilterField1=FirstName&FilterValue1=Boris
I’m always browsing a document library with filtering by specific document type. So I’ve created a simple script. Just add a Content Editor Webpart to your homepage, edit its source and add the following code (just update the url to your document library (docLibUrl):
<script type="text/javascript">
function docLib(dropdown) {
var vtype = dropdown.options[dropdown.selectedIndex].value;
var docLibUrl = "/Shared Documents/Forms/AllItems.aspx";
var filterField = "DocIcon"
if (vtype != ‘Select’) {
document.location=docLibUrl+"?FilterField1="+filterField+"&FilterValue1="+vtype;
}
}
</script>
<select style="margin:10px; 0px;" id="DocumentTypes" onchange="docLib(this)">
<option value="Select">Select document type</option>
<option value="Select">– Office 2007 –</option>
<option value="docx">Word 2007</option>
<option value="xlsx">Excel 2007</option>
<option value="pptx">PowerPoint 2007</option>
<option value="Select">– Office 2003 –</option>
<option value="doc">Word 2003</option>
<option value="xls">Excel 2003</option>
<option value="ppt">PowerPoint 2003</option>
<option value="Select">– Other –</option>
<option value="pdf">Acrobat (PDF)</option>
</select>



This tip encapsulates everything that is great about SharePoint – a platform that provides the opportunity to implement extremely effective solutions simply!
And in sharing this great tip you have epitomised how fantastic the SharePoint community is, thanks.
I can only get this to work if both the field name and the value are a single text string (just as in your example).
What do you do if the field is
Full Name
and the value is
Boris Spassky
?
For FilterField1 you can freely enter spaces, since these will be converted to %20. So for Boris Spassky it will get translated to Boris%20Spassky.
Other story is the space in the FieldName. SharePoint translates spaces in field names to _x0020_.
Underscore (_) gets translated in the URL to %5F so in your case the filter field would be First%5Fx0020%5FName. But this can complicate your life. Just sort by First Name and check url. You’ll find the value in the SortField=… parameter. To finalize the story: In your case the parameters would be:
?FilterField1=Full%5fx0020%5fName&FilterValue1=Boris%20Spassky
There is an exception: If you’re doing this in SharePoint’s built-in list the “SharePoint” column name for Full Name is FullName, the parameters would start FilterField1=FullName. I could go on for quite some time about “SharePoint” column names, but that’s a topic for another post. Like mentioned before – to get the proper FilterField1 value just sort the view (click the column name in allitems.aspx) and watch the SortField parameter value.
Thanks Boris. It was I think the fact that the value accepts %20 but the Field Name doesn’t that got me.
Mike
If I wasn’t heterosexual I’d be kissing you right now.
This was exactly the thing I was looking for
I need a solution to filter one attribute (say ID) not exactly with one value but to two different values. Creating a view is simple, but how to write this in the url?
Chris
I’m not sure if this is possible, since it’s also not possible to do this through GUI dropdowns.
could you tell me if i want to create filter through url but not for exactly value, like filter for Date. i want to get the documents which the end Date < someDate. i have tried use the "greater than" but it is useless. thank you
is it possible to expand groups when the list has groupings set up?
using the url like ?FilterField1=Customer&FilterValue1=Walmart&Expand=true
This is great but I need to be able to filter more than one column.
How do I adapt the code so that I can have 3 drop downs? Then use a button to fire the script which reads the values from each drop down and then sends the URL to filter correctly?
Also on refresh of page after filtering would be great if drop downs displayed the value which the filters are set too.
Hi, Matt.
Multiple filters can be applied by using additional filter URL parameters (FilterField2, FilterValue2,…). I agree that the dropdown should show the selected filter value, but the example above was just a quick demo of how to make the URL Filter.
I believe the best way is to construct those 3 dropdowns using JavaScript so you can dynamically configure them and set the selected value.
hi,
i need to filter the view with more than one value for one of the fields(instead of using AND i want to use OR operator).
is this possible?
thank’s
Unfortunately not. As you can probably see through UI, multiple filters are available only for 1 value per column and using the AND operator for multiple columns.
It would be nice if the selection could be populated from a task list (Via a dataview web part).
I added the call to the docLib to a dataview web part in Designer. Then i changed the .value property to .text and used this to filter the document library. This allowed me to use a task list to populate the dropdown select list dynamically from another SharePoint list. Worked like a champ!
To Boris:
You can easily create a multi-filter in the same way, by using FilterName in stead of FilterFiled:
.. .aspx?FilterName=ID&FilterValue=Boris;Guy
It will filter all lines in your list where ID = Boris OR Guy
One minor point: it is an OR operator within the same column,
and.. I could not find a way to combine this with another filter.
So.. my problem is.. I need a combined filter:
1. a multifilter on f.i. column department (FilterName)
2. a single filter on column month (FilterValue)
Anybody?
Euhm.. to Boris.. solutions can be very simple..
Create a new column (which you do not show, but for filtering purposes only).
The formula of the calcutaed column:
=Department&Month (as in my previous example)
Now I can use FilterName and FilterMultiValue for filtering, based on this new column.
(With some wildcards in it if you like..)
Remark: this is a good solution if you dynamically compose your URL..
(like I do, in an application that gets its parameters from an excel user-interface)
Guy
@guy: Have you tried using FilterField1=…&FilterValue1=…&FilterField2=…&FilterValue2=…
@Boris: this does not give me te chance to combine a MULTI filter with a single filter.
I need to filter on multiple departments and – above that – 1 subject.
==>
filter all lines that are dept 21 OR dept 25 (FilterName=Dept&FilterMultivalue=21;25)
AND that have subject “Ocoo” (FilterField1=Subject&FilterValue1=Ocoo)
Only, you cannot combine FilterName with FilterField ..
Guy
Is there a way to create a “like” (A%) or “contains” (%A%) filter? What about blank values?
I ask because I have a a document library using multiple layers of folders –like a network file share. (Bad practice I know but this is the way the end user set it up even though I recommended using metadata.
Folder_1
+ Folder_A
+ Folder_B
+ Folder_C
+ File_X
Folder_2
+ Folder_A
+ Folder_B
+ Folder_C
+ File_X
When a filter is selected at the top layer (Folder_1), it remains “active” in the secondary secondary layer (Folder_A). This makes the folder look like it is empty because the FL does not match the select value as it is blank — null or empty string.
Any and all help or suggestions would be appreciated. BTW, I am using MOSS 2k7 STD.
@MJM – The solution I found in MOSS 2010 is to navigate to the folder directory you want to display 1ist, and use that location (see URL field) in the page.aspx?rootfolder= in the URL link to get to the page… e.g., see: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/352ff988-8883-4354-88b9-3ad1f16fdc1a
Hi Boris,
Great post which I have been utilising for some time and recently used your code for a drop down to filter a calendar list view which shows numerous corporate board meetings. I did amend the code to include a selector to remove filtering and show the full list again, this uses ?FieldClear=1.
What I would like to be able to do is achieve the same thing with a calendar layout view. Looking at the source html for a modify view page seems to show that it uses FieldPicker and CompareWithValue for filters but I cannot find these calls in the resulting calendar view code or understand how a filter is being implemented.
Can you shed any light on whether it is possible to filter a calendar layout view on-the-fly using the URL. Obviously I could create separate views for each of the 16 boards but would like to find a simpler method if it is available.
Regards,
David
Hi.
Can someone help me with this case?
1. How can I use a multi filter for field firstName and for fieldLast name?
(first name ann* and last name han*;Rob*)
2. How can I differenciate between OR and AND when selecting from FilterFields?
3. I’ve tried to combined a filterfield and a filterMultifield, but it will only take one of them.
Regards,
Sig
I realize this is an old thread, but I’ll give it a try anyway.
Sig: did you manage to solve your problem?
I’m currently struggling with the same thing. I want to AND multiple values from the same field in filters
As far as I know in SP2010 this is doable. Just use FilterField2 and FilterValue2
This solution doesn’t work with DataForm web part. Any solution?
@Van SharePoint: True. You have to implement your own DataForm QueryString parameters and filters using either CAML Query or XSLT Filtering.
Hi,
I’m trying to filter a list using a querystring variable defined in Sharepoint 2010 Designer :
1) I create a view (list01) of my list
2) I define the parameter PARAM whose source will be the querystring variable id_param
3) I define a filter by the [PARAM] parameter
In list01 edit view properties on my site ,in Filter section,I find :
Show items only when the following is true:
Show the items when column
id
is equal to
{PARAM}
I pass the querystring variable by url: “http://mywebsite/Lists/test_list/Lista01.aspx?id_param=100″
I find the error:
“Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.
Correlation ID:022a5776-6f1b-4891-aa7e-574bf2befdd2 ”
Besides,in the filter condition of my view, {PARAM} does not take the querystring value id_param=100,and the javascript validation says:”Filter value is not a valid number”.
Actually it has correctly been defined in SP2010 Designer.
Thank’s for your help
Matteo