Filtering list items in SharePoint based on current user and current user groups


Of late, I was working on a list view where I’ve to filter the items based on the current user and the current user groups. Filtering the items by the current user is a straight forward approach where you can select the user field and set the value to [Me]. But there is no provision in the list view filter page where you can filter the items based on the group specified in the field.

But with the help of designer you can manually edit the CAML of the XSLT list viewer webpart in the view page and use the Membership element to filter based on the group. All you have to do is to use CurrentUserGroups as the membership type to show that particular item for the users in that specified group.

<Or>
  <Membership Type=\"CurrentUserGroups\">
    <FieldRef Name=\"AssignedTo\"/>
  </Membership>
  <Eq>
    <FieldRef Name=\"AssignedTo\"></FieldRef>
    <Value Type=\"Integer\">
      <UserID/>
    </Value>
  </Eq>
</Or>

Let’s consider that an item has the filed value as “Kate, John; Approvers”. The item will be shown to the user John kate as well as the members of the group ‘Approvers’. Remember that you have to set the people or group field to allow multiple values as well as selecting objects from SharePoint groups to hold such a value.

Advertisements

4 thoughts on “Filtering list items in SharePoint based on current user and current user groups

  1. Gris says:

    Using Sharepoint 2010 Standard, how do you filter a list view based on the user profile parameters? For example, let’s say that I have
    -a userprofile field(or property) called “Division”, which is mapped to an AD field.
    -a custom list with these fields: Division, Department, Address.
    How do I filter the list view to only show the listitems for the Division that the user visiting the page belongs to? The result i am looking for is like adding a filter :”where Division=[Division]” (similar with: “where CreatedBy=[Me]” .)
    If i had had Enterprise, I would have used the CurrentUserFilter. How can i accomplish this with Standard version?

  2. Maria says:

    I have several different views in SharePoint 2010 list. I need that views to be shown depended on the user (for example, if Bob opens the list he sees the view1 only and can’t change it, if Kate opens the view she sees only the view2 and can’t change it too). Can anyone help me with this?

  3. Loque says:

    This XSLT list viewer can differentiate it based on the level access of user,like administrator?contributor and visitor depending on their level of permission rite?

Leave a Reply

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