Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I would like to query list and get items that were created by specific user, in my list I have the fild "User" of type Person

I tried this but it didn't work:

<Where>
 <Eq>
  <FieldRef Name='User' />
   <Value Type='Lookup'>1</Value>
 </Eq>
</Where>
share|improve this question
    
What do you mean "it didn't work"? Did you get an error? Were no results returned? What is the ID of the user you are searching for on the site? Where is this code running? –  Kit Menke Feb 10 '12 at 21:59
    
This is working like a charm, my only doubt when i used in u2u caml query tool no results cameup any clues? –  user966391 Jun 15 '13 at 9:34

2 Answers 2

http://www.stum.de/2008/02/06/querying-the-person-or-group-field-using-spquery/

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

1  
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Hugh Wood Feb 23 at 23:22
up vote 7 down vote accepted

Thanks Alex, that article helped!

What I was missing is "LookupId='TRUE'" in the tag should has , the following is the corrected query:

<Where>
 <Eq>
  <FieldRef Name='User' LookupId='TRUE' />
   <Value Type='Lookup'>1</Value>
 </Eq>
</Where>
share|improve this answer
    
I'm glad to help. :) –  Alex Boev Feb 11 '12 at 11:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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