Filtering by Current user CAML query

March 2nd, 2009 | Categories: JavaScript, MOSS, SharePoint

If you need custom CAML (for example in Content Query WebPart QueryOverride) and you need items filtered by Current User – the one that is currently logged in, you can setup the following filter (the example below references the field “Assigned To”:


In the example above what I did was change the value type to Integer and add a LookupId=’TRUE’ attribute to FieldRef node.

How to get the internal name of the field? Here’s one of the ways: In list settings click the name of the column / field for editing its properties


in the URL of the “Change Column” page look for the value of last parameter (Field=…)


If your column name doesn’t contain any special characters (like spaces or other, you have the value), otherwise you can use simple javascript to retrieve the field name. For example if the column name is Številka, the parameter in url will look weird:


To get the field name, copy the value and paste it into the following javascript which you can run from URL in your browser:



and the alert box shows the SharePoint’s internal column name.