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:

  1. Insert the current user filter web part on your web part page
  2. Insert the text filter web part on your web part page
  3. 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.
    ch5[7]
  4. Create a web part connection from the Current User Filter.  Connect it as so:
    Connections –> Send Default Value To –> Text Filter
    ch5[8]
  5. Exit edit mode.  Now your page will look like this:
    ch5[31]

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”.

26 comments

  • What a great tip. Thanks again Laura!

  • Thanks Laura. Great tip.

  • tina.norman@tmwebdesigns.com

    If someone opens the list to edit after it was filled out previously does that change all the fields to the current user information? Thanks

  • Tina, No, it doesn’t on this example, because we’re only editing the “new” item form.

  • Hi Laura, Great tutorial. I have been able to filter a list by user name and I am trying to do the same thing with an external list and it does not work. None of the matching records are displayed. I have just connected the CurrentUserWebPart to the XsltListViewWebPart. Any ideas? Thanks

  • Hi Laura, This works fine until I try to filter and external list, and then it excludes all records, even those that match. Any ideas?

  • kashek85@gmail.com

    Hi Laura, First of all Thanks a Ton. This saved me a lot of time. I tried using these on three fields but unfortunately only User Name Field is being stored in the list after clicking on OK button. Do you know any reason as why will this happen

  • Santi, I do not now, as I have never tried this on an external list. I imagine that the data type must match whatever needs to be stored in that field. Other than double checking that, I’m not sure.

  • kgsolo5000@seznam.cz

    Hi Laura, thanks for your post, it was helpful.. I’ve one question, is it possible to apply this filter on calendar? I’ve tried but without success.. Thanks Jan

  • Jan, No, I don’t know any way to do that on the calendar view itself, it would have to be a list view of the calendar.

  • Thank you so much for the wonderful post! i did as its been instructed and it was working for me until yesterday!! suddently today , when I configure the connection to “get paramaters from” it takes me to a 403 error page! Could you give me your insight pls? Thanks a bunch! Bala

  • Bala, Sorry I have no idea, but it sounds like it’s server or network related. Laura

  • Hi Laura, I need to display Contact Details in “My Site” page and I want to display the contact information of the person that is currently connected. Is there any solution using this Current User Filter Webpart? Do you have any other option? Thanks in advance.

  • Victor, Yes, there’s a web service that you can tap into to get that info. It’s called UserProfileService.asmx Here’s a screencast I did on how to display info from a web service: http://www.endusersharepoint.com/2009/07/07/5-minute-screencast-sharepoint-web-services-for-non-developers/

  • Gracias Laura por tus posts!!

  • hi.. i want to add current user filter web part on my document library if any one knows please help me

  • Rahul, Go to your document library, and click and . Click Add a Web Part. Add the current user filter web part. Done.

  • Hi Laura, I need to filter a library based on user profile information such as Department, Country etc. This works great with one exception – when the consumer field in the library is blank. Essentially I need to filter the library to show docs targeted to the person and also docs where one, two or all of the targeting fields are blank, it would be a chore to make sure the several fields are completed just so a document shows up for one person in a department in a particular country doing a particular role. There are docs that need to be shown to everyone in the same library. Any idea how to do this? Cheers, Pete.

  • Hi Laura, I have just worked the solution to this out … I have created some parameters in my library view in SPD, and I am then passing the filter values from the Current User WPs that are on the page to the parameters. I can now filter the library view by the parameter or if the column is null. Works well. Cheers, Pete.

  • Laura, do you have an updated link for using the asmx in SPD 2010? I need to read the “department” field from the user profiles data, and based on that value filter a listview , so when I go to the list view, I will only see items that pertain to the department I have set in my user profile.
    For example I have a list called Projects and it has these listitems:
    ProjName Dept
    Proj1 IT
    Proj2 HR
    Proj3 IT
    Proj4 CustService

    Because I am an IT person (and in my profile I have dept=IT), when I go to this list (or a custom view of it) , I should only see Proj1 and Proj3.

  • And I forgot to mention, I dont have enterprise, so i can not use the Current User Filter webpart.

  • Fantastic post, Laura!
    Very helpful indeed.
    Phil

  • Gris,
    I do not know of a way of obtaining the current user’s department name without enterprise. Maybe research some jQuery blogs to see if they have a way with code?

  • TomW (@tmwilliams949)

    This work great! (Uh, the FIRST time.) Then it says the parts are not connected (but warns about breaking the exact existing connection when I reset it. If I delete both parts and redo the whole thing (pulling a different field from the current user filter for example) it works great again (but only once). Can you suggest what I might be doing wrong? What happens when one of the fields you try to pull isn’t populated? Thanks!

  • Tom,
    After you set this up, save the page, do a hard refresh on the page to see what you see. Also, if your field in the current user profile has no data in it, then your text box will just show as blank. Also, I wouldn’t worry about the message that says they’re not connected. If you know you created a connection, you can ignore that message.

  • It’s the small stuff that makes a big difference. Thanks for the tip.

Leave a Reply