Filter list views by user groups

Though SharePoint Designer is a powerful tool, but even then there is a limitation to filter list views by user group. Only filter that can be applied is by using keyword [Me]. So if current user is the member of any group, then the [Me] keyword filter won't work.

The alternative idea is to use the Membership comparator, which is used by the "By My Groups" view. The Membership comparator seems to work just like the other comparators ("is equal to", "is greater than", "is less than", etc), but is not available in the "Filter" section of view.

Try following these steps:

  • Create a new view, and open the corresponding Aspx in Sharepoint Designer
  • In the source code, locate the ListViewXml tag
  • Inside this tag, locate the Where clause (begins with "<Where" and ends with "/Where>")
  • Replace the contents of this tag with the following:
<Where><Or><Membership Type="CurrentUserGroups"><FieldRef Name="AssignedTo"/></Membership><Eq><FieldRef Name="AssignedTo"/><Value Type="Integer"><UserID Type="Integer"/></Value></Eq></Or></Where>
Save the page, and you're ready to go.

No comments: