Testing the Current User Filter Web Part
This post applies to the enterprise version of SharePoint.
The out of box web part called the Current User Filter is extremely useful, and I mention it in several of my blog posts. This web part is also a bit of a hassle sometimes, though, because it’s usually not entirely apparent what data is being output from it.
The way it works is that it looks at who the current logged in user is, and looks at the values in their profile properties, such as name, department, etc. You pick one profile property to look up, and then connect the current user filter to another web part to send filter information or parameters.
The problem is that sometimes you can’t tell if it’s working or not, or what value it’s sending to the other web part. The trick for testing the output is to use the text filter also. Here’s how:
- Insert the current user filter web part on your web part page
- Insert the text filter web part on your web part page
- In this example, we’ll be using the current user’s department name, so go to the current user filter’s web part properties, and change the profile value drop-down to “Department”. Click OK.
- Create a web part connection from the Current User Filter. Connect it as so:
Connections –> Send Default Value To –> Text Filter
- Exit edit mode. Now your page will look like this:
Notice that the current user filter web part doesn’t show at all, and the value of the current user’s department is now shown in the text filter.
So, you could use this just to test values just to make sure the web part works as planned, and you could also use it as part of a solution. You could then connect the text filter web part to pass a filter value to a list view web part or library. That way, the list would show your own department by default, but then you could type the name of another department if you wanted users to be able to do that.
One example of a place where I’ve recently used the current user web part: In an InfoPath form, there is a department name that gets filled out. When people look at this form library, I have filtered the list of forms by the current user’s department, so that they see their own department’s forms by default.
Side note: In SharePoint 2010, the filter web parts don’t seem to work very well on wiki pages. Sometimes they simply disappear. If you used the team site template when creating your 2010 site, and you don’t want the home page to be a wiki, you can disable the site feature called “Wiki Page Home Page”.