Passing Filter Parameters Through SharePoint URLs

Here’s a neat trick I figured out the other day.  It didn’t actually solve my problem, but I figured it was worth documenting in case it comes in handy in the future.  My goal was to add filter parameters to a URL so that it would automatically filter for specific elements.

This sort of technique could be used to point users or a page viewer webpart from a project workspace back to a centralized document repository, the likes of which I described in this post.

So first off, we need the URL of the list.  Since I have the Contoso demo environment open, I’ll just use the sample report library in the BI Center.

http://project.contoso.com/PWA/ProjectBICenter/Sample%20Reports/Forms/AllItems.aspx

image

Now let’s filter on all items where Modified By = Marc Soester.  We need to identify how the system is referring to the Modified By field.  To do this, click on the Library tab, and select the Library Settings option.  Click on the Modified By field in the middle of the page.

That will yield a page that looks like this:

image

Take a look at the URL:

http://project.contoso.com/PWA/ProjectBICenter/_layouts/FldEditEx.aspx?List=%7B0AE8F9C9%2D0277%2D40DE%2DAFAB%2D25B10127CC3A%7D&Field=Editor

That last bit is what we’re looking for.  Internally, SharePoint refers to the Modified By field as the Editor field.

So now we take the original URL and add the following string:

?&FilterField1=Editor&FilterValue1=Marc%20Soester …to yield the following URL:

http://project.contoso.com/PWA/ProjectBICenter/Sample%20Reports/Forms/AllItems.aspx?&FilterField1=Editor&FilterValue1=Marc%20Soester  

Click on that, and you get a filtered list:

image

Want to filter on two fields?  Use the following syntax:

http://project.contoso.com/PWA/ProjectBICenter/Sample%20Reports/Forms/AllItems.aspx?&FilterField1=Editor&FilterValue1=System%20Account&FilterField2=DocIcon&FilterValue2=vdw

…which will filter on all Visio Drawings (VDW) created by the System Account.

image

Passing Filter Parameters Through SharePoint URLs