Forum Discussion
rautchetan27
May 27, 2020Brass Contributor
CAML query to filter List items on the basis of Current User group in sharepoint
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>
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>
- Sudharsan KSteel Contributor
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>
- rautchetan27Brass Contributor
Thanks, its working now after makings some changes in column type