Querying By Display Name:-
Here is how to querying for Person or Group field by Display Name. Things that you have to concern here are Value Type is “User” and [User_Name] must be replaced with the Display Name (SPUser.Name) of the user.
Write the query as following:
<Where>
<Eq>
<FieldRef Name='UserID' />
<Value Type='User'>[User_Name]</Value>
</Eq>
</Where>
Querying By User ID:-
Advantage of querying by User ID is this will avoid failing of querying by Display Name when you have users who have same value for it. Here the most important thing to concern is that you have to add LookupId=”TRUE” property in FieldRef tag and also should replace [User_ID] with the ID (SPUser.ID) of the user.
Write the query as following:
<Where>
<Eq>
<FieldRef Name='UserID' LookupId='TRUE'/>
<Value Type='User'>[User_ID]</Value>
</Eq>
</Where>
No comments:
Post a Comment