2

I have added the following filter inside a view:-

enter image description here

Which will filter if the “Assigned To” field equals the logn user. But now if the “assigned to” field contain a group which I belong to, then the filter [Me] will not be able to detect this. So is there a way to say something [MYGroups] to check if I am within the inserted assigned to group ?

Edit i tried this query tag :-

<Query><GroupBy Collapse="FALSE" GroupLimit="30"><FieldRef Name="_ModerationStatus" Ascending="FALSE"/></GroupBy><OrderBy><FieldRef Name="Modified" Ascending="FALSE"/><FieldRef Name="FileLeafRef"/></OrderBy><Where><And><Or><Membership Type=\"CurrentUserGroups\">
<FieldRef Name=\"AssignedTo\"/>
</Membership><Eq><FieldRef Name="Assinged_x0020_to"/><Value Type="Integer"><UserID Type="Integer"/></Value></Eq><Eq><FieldRef Name="Assinged_x0020_to"/><Value Type="Text">admin</Value></Eq></Or><Eq><FieldRef Name="_ModerationStatus"/><Value Type="ModStat">pending</Value></Eq></And></Where></Query>

but this have raised an exception when i tried to open the view?

1
  • 1
    You can only OR two things at a time in CAML. So you need to nest another OR
    – AdamBT
    Commented Sep 12, 2014 at 15:04

1 Answer 1

1

From: http://www.makdeniz.com/how-to-filter-sharepoint-2010-tasks-which-are-assigned-to-you-and-the-group-your-are-member-of/

Step 1:

Open SharePoint designer then open site that you want to study. Select the task list or any list that you want to filter. When you select task list you will see a panel right site of designer called views. Then select the view that we will modify.

Step 2:

If you can not edit file you must select advanced edit mode

Step 3

In source view search for and you will see view query. If you already modify view as filtered by [Me] you are going to see more or less query as shown in picture. Modify this query string with code given below. that’s how user can see tasks which are assigned to him or his group.

Step 4:

The key ingredient is “CurrentUserGroups”. Now you can modify any list and make different types of filter. This query syntax called CAML. If you study little bit, then you can make complex query or what ever you want.

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

  </Or>
7
  • my current query looks as follow"<Query><GroupBy Collapse="FALSE" GroupLimit="30"><FieldRef Name="_ModerationStatus" Ascending="FALSE"/></GroupBy><OrderBy><FieldRef Name="Modified" Ascending="FALSE"/><FieldRef Name="FileLeafRef"/></OrderBy><Where><Or><Eq><FieldRef Name="Assinged_x0020_to"/><Value Type="Integer"><UserID Type="Integer"/></Value></Eq><Eq><FieldRef Name="Assinged_x0020_to"/><Value Type="Text">admin</Value></Eq></Or></Where>" so where i should add the Group filter exactly ?
    – John John
    Commented Sep 12, 2014 at 14:31
  • You need another OR for "CurrentUserGroups": <Membership Type="CurrentUserGroups"><FieldRef Name="AssignedTo"/></Membership>
    – AdamBT
    Commented Sep 12, 2014 at 14:38
  • but i am not sure why exactly i need to place this ? there are many <and> and <or> tags?
    – John John
    Commented Sep 12, 2014 at 14:42
  • 1
    You are "ORing" 2 AssignedTo's, you need to add another for 'CurrentUserGroups' (The membership tag in my previous comment) ... I added some CAML to the answer to make it more clear.
    – AdamBT
    Commented Sep 12, 2014 at 14:48
  • 1
    I modified the CAML for your specific situation.
    – AdamBT
    Commented Sep 12, 2014 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.