0

I am making use of CAML Query to filter the records from list into DataTable. I have a SPUser Field in my list.

I am endeavoring to obtain the user id of each user in CAML Query. Any insights on how to achieve this?

1 Answer 1

2

Get items for an SPUser.ID:

<Where><Eq><FieldRef Name='Person' LookupId='TRUE'/><Value Type='Integer'>45</Value></Eq></Where>

Get items for the current user:

<Where><Eq><FieldRef Name='Person' LookupId='TRUE'/><Value Type='Integer'><UserID/></Value></Eq></Where>

Get items for a user's display name (what is displayed normally in the list):

<Where><Eq><FieldRef Name='Person'/><Value Type='Text'>Lastname, Raghu</Value></Eq></Where>

4
  • ...Thank you very much for your reply..But my requirement is that I need to get a separate field using CAML Query which holds the IDs of all the users present in the list. Hope you get my point
    – Raghu
    Commented Aug 6, 2010 at 11:26
  • I'm not sure if I understand... a CAML query controls which rows are returned (not which fields). If you want to control which fields are returned, use the SPQuery.ViewFields property: msdn.microsoft.com/en-us/library/…
    – Kit Menke
    Commented Aug 6, 2010 at 15:38
  • .yes you are right...I know about the SPQuery.ViewFields property...however I need to obtain a field (User ID) from the list which doesn't exist in the list
    – Raghu
    Commented Aug 7, 2010 at 6:47
  • Oh I think I understand.. take a look here: stackoverflow.com/questions/1835355/…. Once you have the SPUser object you'll be able to get ID as well.
    – Kit Menke
    Commented Aug 7, 2010 at 13:45

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.