Filter on current user with CAML Query.


Hi everybody,

Today I will give you a little trick with CAML Query: how to retrieve the current user.

Logic suggests that we write a query like this:

 <Eq> <FieldRef Name='AssignedTo' /> <value Type='User'> [Me]</ Value> </ Eq>  

But then, it does not work …
The proper way to retrieve the current user is to change our query like this.

 <Eq><FieldRef Name='AssignedTo' /><Value Type='Integer'><UserID Type='Integer'/></Value></Eq> 


And that way we get the current user.

Christopher.

Advertisements

4 thoughts on “Filter on current user with CAML Query.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s