Saturday 2 November 2013

Filter SharePoint List Using URL Parameters

When you filter a list in SharePoint, you will notice that the parameters for filtering are appended automatically to the URL of the page that displays the list. So if you have a requirement to create a custom Search page, you can use the url parameters. For example, using SharePoint designer, you can add the list view web part on the page and then manipulate the url parameters for filtering by using javascript.

Here are the parameters that can be added in the URL to filter the SharePoint list:

  • to filter by one column

               ?FilterField1=<InternalName>&FilterValue1=<Value>

  • to filter by one column with multiple values

              ?FilterName=<InternalName>&FilterMultiValue=<value1>;<value2>
                         ** FilterMultiValue should be semicolon separated

  • to filter by two columns

              ?FilterField1=<InternalName>&FilterValue1=<Value1>&FilterField2=<InternalName>&FilterValue2=<Value2>


Note:
   <InternalName> = the internal name of the column
   <Value> = the value of the column


Examples:

1. To display SharePoint list items where Document Date = '08/16/2011'

http://www.vpc.com/sites/blog/Lists/Posts/AllPosts.aspx?FilterField1=DocumentDate&FilterValue1=08/16/2011

2. To display SharePoint list items where Category = 'Category1' and Document Date = '08/16/2011'.

http://www.vpc.com/sites/blog/Lists/Posts/AllPosts.aspx?FilterField1=PostCategory&FilterValue1=Category1&FilterField2=DocumentDate&FilterValue2=08/16/2011

3. To display SharePoint list items where Title = 'Test' OR Title = 'Sample Title'

http://www.vpc.com/sites/blog/Lists/Posts/AllPosts.aspx?FilterName=Title&FilterMultiValue=test;sample%20title

4. To display SharePoint list items where Title contains 'sample'

http://www.vpc.com/sites/blog/Lists/Posts/AllPosts.aspx?FilterName=Title&FilterMultiValue=*sample*





1 comment:

  1. how can you filter out with a date range?
    ex: Category = 'Category1' and Document Date >= '08/16/2011' and Document Date <= '08/16/2012'

    ReplyDelete