6

I would like to dynamically construct a couple of URLs for our SharePoint users to filter down a rather large list view we have. Rather than create a bunch of different custom views, I was wondering if there is a way to just pass some URL arguments to the AllItems.aspx page and have the filter be applied during page load.

I envision maybe create a text box where they can type a question like "DocumentID" and give it a value of "12345" - then have javascript construct an appropriate URL like:

http://server/site/Lists/Links/AllItems.aspx?MyFilter=DocumentID:12345

5 Answers 5

16

If you filter manually, you'll see that the URL changes, e.g. to something like

http://server/site/Lists/Links/AllItems.aspx?FilterField1=DocumentID&FilterValue1=650

So if you pass the parameters FilterField1 and FilterValue1 accordingly, it should work.

2
  • 1
    This worked like a charm - exactly what I was looking for. Thanks!
    – Goyuix
    Commented Jun 25, 2010 at 15:04
  • it's don't work when you have to filter multiples lists
    – user9181
    Commented Jun 29, 2012 at 1:03
1

I wouldn't recommend customizing a regular SharePoint view page in this way. You could create another page though outside of the list or library and put a dataview on there that uses the URL input property.

3
  • Can you elaborate ?
    – frenchone
    Commented Mar 29, 2017 at 8:29
  • 1
    @frenchone, Mike is saying that it is not best practice to edit pages in the /Lists/MyList/ directory of a site. Instead, create a page in the Site Pages or Pages libraries and add a List View Web part of the desired list. From there you can add whatever you want to the page safely. Commented Dec 12, 2017 at 20:00
  • That's more clear. But: OP does not edit pages he filters existing list using url. I guess OP want a dynamic filter, this can't be done using LVWP (or can it ?) And if this can be done, how would it be different (/better) from directly filtering through url filter ?
    – frenchone
    Commented Dec 13, 2017 at 8:55
1

To use the query string parameters as filters you can use the Query String Filter Web Part and connect to a List View Web Part on a Web Part page.

2
  • 1
    Keep in mind that the Filter Web Parts require an Enterprise license. Commented Jun 25, 2010 at 0:49
  • Query String Filter Web Part definitely the way to go (if available to you).
    – matt
    Commented Sep 3, 2015 at 18:52
1

Hi this was a useful post ( I know it is old but I found it!), but I ran into problems with my URL and characters that the string builder didn't like - the 'you cant have [%%]' error message

My link was this kind of thing:

http://foobar/Lists/ECR%20System%20Build/AllItems.aspx?View={by%20ECR%20status}#InplviewHashf777aa1d-dde8-4d51-b8d1-18b514c226f9=FilterField1%3DECR%255Fx0020%255FID-FilterValue1%3D417 (where 417 was the ID in my lookup list)

I already had a lot of rows and wanted to fix them up retrospectively. The concatenation idea didn't seem to work for me.

so I did this (after copying a filtered view URL that worked and adapting it)

I made a string type workflow variable:

then set variable systemslink to    http://collaborate/sites/trustwide/openriocomm/Lists/ECR System Build/AllItems.aspx?View=All Items#InplviewHashf777aa1d-dde8-4d51-b8d1-18b514c226f9=FilterField1=ECR%255Fx0020%255FID-FilterValue1=[%Current Item:ID%], my hyperlink label

then I copied that variable value into my destination hyperlink type column Systems view:

.. then set Systems view to Variable:systemslink

and this worked beautifully, when added to my 'on creation' workflow.

to fix up the others I used an MS access update query, where the syntax is quite different:

UPDATE [ECR Tracker] SET [ECR Tracker].[Systems view] = "See System Build(s)#http://foobar/Lists/ECR%20System%20Build/AllItems.aspx?View={by%20ECR%20status}#InplviewHashf777aa1d-dde8-4d51-b8d1-18b514c226f9=FilterField1%3DECR%255Fx0020%255FID-FilterValue1%3D" & [ID] & "#";

Hope this helps someone.

0

Heres a post i wrote to demonstrate how we can filter a SharePoint list view web part with JavaScript.

Uses the same concept as suggested by Modery

http://rahul-vartak.blogspot.com/2010/08/sharepoint-2007-filtering-list-view-web.html

Hope this is useful..:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.