Filtering list items using CAML query

%3CLINGO-SUB%20id%3D%22lingo-sub-1415585%22%20slang%3D%22en-US%22%3EFiltering%20list%20items%20using%20CAML%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1415585%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20List%20which%20having%20column%20name%20Vendor%20and%20I%20want%20to%20filter%20list%20one%20the%20basis%20of%20Vendor%20name%3C%2FP%3E%3CP%3EI%20am%20using%20CAML%20query%20and%20its%20working%20fine%20if%20I%20am%20passing%20hardcoded%20value%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CWHERE%3E%3CEQ%3E%3CFIELDREF%20name%3D%22'Vendor'%22%3E%3C%2FFIELDREF%3E%3CVALUE%20type%3D%22'Text'%22%3E'IBM'%3C%2FVALUE%3E%3C%2FEQ%3E%3C%2FWHERE%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20I%20want%20to%20make%20it%20dynamic%2C%20instead%20of%20Hardcode%20Value%20'IBM'%20%2C%20I%20want%20to%20fetch%20this%20value%20from%20current%20user%26nbsp%3B%20sharepoint%20group%2C%20so%20If%20current%20users%20group%20is%20'IBM'%20%2C%20he%20only%20shee%20list%20items%20where%20column%20vendor%20value%3D'IBM'%3C%2FP%3E%3CP%3Eif%20current%20users%20group%20is%20'Microsoft'%20he%20can%20only%20see%20list%20items%20having%20value%20in%20vendor%20column%20as%20'Microsoft'%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehow%20can%20I%20make%20above%20CAML%20query%20dynamic%20by%20passing%20current%20users%20group%20in%20query%3F%3C%2FP%3E%3CP%3Esomething%20called%26nbsp%3B%3CMEMBERSHIP%20type%3D%22%26quot%3BCurrentUserGroups%26quot%3B%22%3E%2C%20but%20I%20am%20not%20sure%20how%20to%20user%20that.%3C%2FMEMBERSHIP%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1415585%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Contributor

I have List which having column name Vendor and I want to filter list one the basis of Vendor name

I am using CAML query and its working fine if I am passing hardcoded value

 

<Where><Eq><FieldRef Name='Vendor' /><Value Type='Text'>'IBM'</Value></Eq></Where>

 

Now I want to make it dynamic, instead of Hardcode Value 'IBM' , I want to fetch this value from current user  sharepoint group, so If current users group is 'IBM' , he only shee list items where column vendor value='IBM'

if current users group is 'Microsoft' he can only see list items having value in vendor column as 'Microsoft'

 

how can I make above CAML query dynamic by passing current users group in query?

something called <Membership Type="CurrentUserGroups">, but I am not sure how to user that.

0 Replies