SharePoint Views [Me]-Filter in Schema.xml

Everybody knows the [Me]-Filter in views. It is a nice way to help me seeing my items. This filter is set in SharePoint pretty fast.. you just need to modify you view, scroll down to the filter region and select a person field and show it if its equals the value "[Me]".
It looks like this:



In this case the view shows only items if I am the creator of this item.
But how should you do it in your solution?
What you need to do is to open up your schema.xml of the list. In here you are looking for the "<Views>" tag. Search your view and step into the "<Query>" tag.
Inside the "<Where>" tag you can build the filters. This is nothing else than building up a CAML query. The query for the [Me]-filter looks like this:

1
2
3
4
5
6
7
8
<Where>      
  <Eq>
    <FieldRef Name="Author" />
    <Value Type="Integer">
      <UserID Type="Integer" />
    </Value>
  </Eq>
</Where>

Add the snippet and deploy.. your view should be filtered now.

Comments

Popular posts from this blog

How to support multiple languages in WPF