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.
    198-image_3_36F81541.png

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.

    1. Make sure you have a person field in your list/library, and it lets you pick people or groups.  I’m calling mine “Approver”.
    2. For your list or library where you want to add this functionality, click to create a new view.  Choose standard view.
    3. 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.
    4. Click OK.
    5. In SharePoint Designer, click lists and libraries on the left, and click the name of your list or library.
      198-image_18_36F81541.png
    6. Click the name of your view in the Views section on the right.
    7. 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.

      198-image_19_36F81541.png

    8. 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>
      <Or>
      <Eq>
      <FieldRef Name=”Approver”/><Value Type=”Integer”><UserID/></Value>
      </Eq>
      <Membership Type=”CurrentUserGroups”><FieldRef Name=”Approver”/></Membership>
      </Or>
      </Where></Query>

8/18/2016 Update:  Tried this old post in my SharePoint Online in Office 365 tenant, and had to use this new syntax instead:

<Query><Where>
<Or>
<Membership Type=”CurrentUserGroups”>
<FieldRef Name=”AssignedTo”/>
</Membership>
<Eq>
<FieldRef Name=”AssignedTo”></FieldRef>
<Value Type=”Integer”>
<UserID/>
</Value>
</Eq>
</Or></Where></Query>

 

 

 

 

Advertisements

6 comments

  • You just changed my life.

    Like

  • Thanks for this helpful article , but I have custom list and need to show the items for the current user if he belong to one group, how to do this

    Like

  • Ammar,
    Just create some other query on that custom list, so that you can go find the query code, then replace it with that query syntax that I showed, in your code view.

    Like

  • Hi Laura,
    The code isn’t working & when I create a new Task list (or let SharePoint create on by setting up a workflow) I don’t get the By My Groups view. The CAML code is: –

    Query>

    0

    I want to show only incomplete tasks assigned to me or my groups.

    Please help. Thank you.

    Like

  • Hi Laura,

    This works mostly: –

    Completed

    But it shows all tasks. I can’t get it to work just showing Incomplete & Ordered by Due Date (Ascending).

    Thank you.

    Like

  • It looks like none of this works anymore in SharePoint online. I tried this week, to no avail.

    Like

Leave a reply or question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s