Filter a View by “Me” Without a People Column
This applies to the Enterprise version only, for SharePoint 2007 or 2010.
A lot of times, especially with InfoPath fields, you end up with a text field with a user’s name in it, instead of an actual people picker field. The syntax may be something like DOMAINusername. In this post, I’ll use the example of “Current Approver”. This text field is not very useful, though, when trying to create a filtered view where that text field (Current Approver) is equal to [Me], the logged in user. Sometimes if I’ve got a text field with a name in it and want users to be able to see a view of their own items, I’ll even create a new people field in the list, and create a workflow that copies the name value over from the text field to the people picker. This gives a nice, pretty people field, and gives you the ability to filter by Current Approver is equal to [Me].
In this post, I’ll show you a quick way to show users a view of items applicable to “Me”, without having to go to the trouble of creating an extra people picker field just to be able to use [Me].
Here’s the example list, and you see the “Current Approver” column is just a text field. The next step is to filter this view so that the logged in user only sees items with their own name as the current approver.
- Click <Site Actions>, and choose <Edit Page>
- Click to Add a New Web Part, and add the Current User Filter web part to the page.
- Take a look at the current user filter web part settings in the web part toolpane. You’ll notice that by default, the value that is stored in this web part is the current users’ DOMAINusername. There is also a drop-down box where you can pick the user’s email address, department, etc. I’m going to leave the default.
- Create a web part connection from the Current User Filter web part. Choose to Send Filter values to, and then choose the consumer web part, which is the SharePoint list you want to filter.
- Pick the “Current Approver” or whatever field contains your user names, and click Finish, and exit edit mode.
- This is what the final, filtered view looks like:
In SharePoint 2010, you can safely remove the “Current Approver” column from the view if you don’t need to see it. In SharePoint 2007, it won’t allow you to create a connection to a column that isn’t displayed in the view (unless the view is a data view web part). Remember that this same thing can be done with other types of user name syntax, like the email address or full name. Done!
If you’d like to learn more about how you can test to see what values are being passed from the Current User Filter web part, read my post: Testing the Current User Filter Web Part
Laura, do you know of any way to filter a view based on a property of the current logged in user, when you don’t have the Current User Filter web part? (ie, in WSS or Foundation?)
Keith, that could be possible with SPServices: 1) Get the property http://www.modery.net/1_moderynet_–_share-manage-govern/archive/644_fetching_the_current_userrsquos_office_location_with_spservices.html http://sympmarc.com/2010/10/29/capturing-the-current-users-manager-in-moss-using-spservices-and-getuserprofilebyname/ 2) Apply the filter http://www.sharepointoverflow.com/questions/3688/filter-a-list-view-using-url-parameters/3692#3692
Keith, No, it’s not possible out of box, but I would definitely take a look at Rene’s solution there.
This does not work for me in SP2007 Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION)) Troubleshoot issues with Windows SharePoint Services.
This is great. I am using SP and Infopath 2010 and I have a list of appox. ten users. I would like to filter based on the current user being in that list. I am at my wits end. I have a list of projects containing list of users an those users should have the abilty to automatically see their own projects. Do you have any suggestions? Thank you
“group of users”, Do you have the enterprise version? If you only want a certain set of users to see the whole web part, you can set an audience in the web part settings. Then, you can use that in combination with my method with the current user filter. (If I understand the problem correctly)
Great post! It worked for me on single line of text column(Domain\Account) ,but not working on email or full name etc?
any workaround for this?
You can just pick a different field at step 3. See my other blog post for more info:
Hi Laura, I know this is a very old post, but I encountered an issue trying to use this process in SP 2013. The Current User Filter is trying to pass the default user ID parameter with those funky leading characters: (i:0#.w|DOMAIN\username)
Those leading characters appear to be throwing off the filter. Lori Gowin has a workaround for this for InfoPath. Any thoughts on how to make this work with this quirky code?
Just use username in the web part settings drop down box, instead of that default one it uses.
Hello Laura, I created the filter on an external list. I still however would like the department to be able to switch to “all items view” without having to remove the web part. As long as the web part exists it only shows the current user view but I can’t get back to the all items view. Could you please shed some light on this issue?