The “My Groups” View
In SharePoint 2010/2013, there’s a cool little feature in task lists that lets you create a view that shows you all items assigned to any SharePoint groups that you’re a member of. Even though it’s not as apparent in other lists, this post will show you how to accomplish it using SharePoint Designer. This solution can be done in either SharePoint 2010 or 2013, with your corresponding version of SharePoint Designer.
- Create a task list in SharePoint 2010 or 2013. Notice that there’s a default view in the list called “By My Groups”.
- Create a task, and in the Assigned To box, pick a group that you are a member of. Create another task and assign it to a group you’re not a member of. Notice that the “By My Groups” view will only show you the tasks assigned to groups you’re in. It doesn’t show items that are assigned to groups I’m not in, and doesn’t show items that are assigned to me individually.
So, it’s just a matter of hacking into the code to see what’s going on. I have a library where I associate each item in the library with a group of people, for approvals to take place. I want to be able to have a single view, where everyone can view their group’s items.
- Make sure you have a person field in your list/library, and it lets you pick people or groups. I’m calling mine “Approver”.
- For your list or library where you want to add this functionality, click to create a new view. Choose standard view.
- You can call the view “My Groups” or whatever you’d like. In the filter section, just add any filter at all. It’s not relevant and will be removed later, we’re just using it as a placeholder. Just “Created By” is equal to [me] or anything at all.
- Click OK.
- In SharePoint Designer, click lists and libraries on the left, and click the name of your list or library.
- Click the name of your view in the Views section on the right.
- Now, the trick is to find in the code, the filter that you just created. The whole point was to find your filter and replace it with this special filter for groups. You’ll find a part of the code (mine’s on line 34) that has <Query><Where> in it, and it ends with </Where></Query>. This is the filter. Here’s what you replace that whole thing with:
<Query><Where><Membership Type=”CurrentUserGroups”><FieldRef Name=”Approver“/></Membership></Where></Query>Notice that the field name Approver matches step 2 where I called my people field Approver.
- See that I put the query on its own line, even though it had originally all been crammed onto line 34. Again, be sure to change the field name to your own, and click Save.Done! Now, when you’re on that view, you’re only going to see the items where the “Approver” field contains a SharePoint list that you’re a member of.Added 9/3: If you want the query to show everything that is assigned to you OR a group you’re in, you can use this syntax:<Query><Where>
<FieldRef Name=”Approver”/><Value Type=”Integer”><UserID/></Value>
<Membership Type=”CurrentUserGroups”><FieldRef Name=”Approver”/></Membership>
8/18/2016 Update: Tried this old post in my SharePoint Online in Office 365 tenant, and had to use this new syntax instead: