Filter a View by “Me” Without a People Column
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 DOMAIN\username. 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' DOMAIN\username. 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