SOLVED

CAML query to filter List items on the basis of Current User group in sharepoint

%3CLINGO-SUB%20id%3D%22lingo-sub-1421824%22%20slang%3D%22en-US%22%3ECAML%20query%20to%20filter%20List%20items%20on%20the%20basis%20of%20Current%20User%20group%20in%20sharepoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1421824%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20List%20library%20which%20having%20column%20Name-Vendor%2C%20also%20I%20have%20differ%20sharepoint%20user%20groups%20for%20each%20vendor.%3C%2FP%3E%3CP%3EI%20am%20using%20CAML%20query%20to%20filter%20List%20items%2C%20so%20user%20can%20see%20list%20items%20belong%20to%20its%20vendor%20group%20only.%3C%2FP%3E%3CP%3EI%20am%20filtering%20List%20items%20using%20CAML%20query%26nbsp%3B%20where%20value%20of%20currentuser%20group%20will%20be%20same%20as%20Value%20in%20Column%20of%20list%20items-Vendor%3C%2FP%3E%3CP%3EI%20am%20using%20following%20CAML%20query%2C%20is%20this%20correct%2C%20I%20am%20not%20getting%20expected%20filter%20result.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CWHERE%3E%3CEQ%3E%3CFIELDREF%20name%3D%22%26quot%3BUser_ID%26quot%3B%2F%22%3E%3CVALUE%20type%3D%22%26quot%3BText%26quot%3B%22%3E911%3C%2FVALUE%3E%3C%2FFIELDREF%3E%3CMEMBERSHIP%20type%3D%22%26quot%3BCurrentUserGroups%26quot%3B%22%3E%3CFIELDREF%20name%3D%22'Vendor'%22%3E%3C%2FFIELDREF%3E%3C%2FMEMBERSHIP%3E%3C%2FEQ%3E%3C%2FWHERE%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1421824%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ecaml%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1429263%22%20slang%3D%22en-US%22%3ERe%3A%20CAML%20query%20to%20filter%20List%20items%20on%20the%20basis%20of%20Current%20User%20group%20in%20sharepoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1429263%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F670519%22%20target%3D%22_blank%22%3E%40rautchetan27%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20to%20use%20the%20below%20code%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3COR%3E%0A%20%20%3CMEMBERSHIP%20type%3D%22%5C%26quot%3BCurrentUserGroups%5C%26quot%3B%22%3E%0A%20%20%20%20%3CFIELDREF%20name%3D%22%5C%26quot%3BAssignedTo%5C%26quot%3B%2F%22%3E%0A%20%20%3C%2FFIELDREF%3E%0A%20%20%3CEQ%3E%0A%20%20%20%20%3CFIELDREF%20name%3D%22%5C%26quot%3BAssignedTo%5C%26quot%3B%22%3E%3C%2FFIELDREF%3E%0A%20%20%20%20%3CVALUE%20type%3D%22%5C%26quot%3BInteger%5C%26quot%3B%22%3E%0A%20%20%20%20%20%20%3CUSERID%3E%3C%2FUSERID%3E%0A%20%20%20%20%3C%2FVALUE%3E%0A%20%20%3C%2FEQ%3E%0A%3C%2FMEMBERSHIP%3E%3C%2FOR%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1429582%22%20slang%3D%22en-US%22%3ERe%3A%20CAML%20query%20to%20filter%20List%20items%20on%20the%20basis%20of%20Current%20User%20group%20in%20sharepoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1429582%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F144422%22%20target%3D%22_blank%22%3E%40Sudharsan%20K%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20its%20working%20now%20after%20makings%20some%20changes%20in%20column%20type%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

I have List library which having column Name-Vendor, also I have differ sharepoint user groups for each vendor.

I am using CAML query to filter List items, so user can see list items belong to its vendor group only.

I am filtering List items using CAML query  where value of currentuser group will be same as Value in Column of list items-Vendor

I am using following CAML query, is this correct, I am not getting expected filter result.

 

<Where><Eq><FieldRef Name="User_ID"/><Value Type="Text">911</Value></Eq><Membership Type="CurrentUserGroups"><FieldRef Name='Vendor' /></Membership></Where>

2 Replies
Highlighted
Solution

Hi @rautchetan27 

Try to use the below code

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

@Sudharsan K 

Thanks, its working now after makings some changes in column type