SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I try to filter items in the list by using caml. The List contains elements that matches the Filter.

The code:

enter code here

SPQuery qry = new SPQuery();
            qry.Query =
            @"   <Where>
                     <FieldRef Name='Gesch_x00e4_ftsbereich' />
                     <Value Type='Text'>FHC</Value>
            qry.ViewFields = @"<FieldRef Name='Gesch_x00e4_ftsbereich' /><FieldRef Name='Dokument' />";
            SPList akten = web.Lists.TryGetList(ListNameAkten);

            // get the items
            SPListItemCollection aktenCollection = akten.GetItems(qry);

Now when I execute the query like obove, I get a resultset of 0. When I remove the ViewFields Parameter, I got hte same result.

What I'm doing wrong? Doesn't Sharepoint Online (365) doesn't support caml?!

share|improve this question
SharePoint 365 supports CAML. Have you try to do the same query with a tool like a caml designer: – Salvatore Di Fazio Feb 6 '13 at 11:33
Just to double-check: Are you querying a text field? – Stuart Pegg Feb 6 '13 at 11:54
Hi this field ist a normal textfield. And the value already exists. – Sascha Feb 6 '13 at 12:11
up vote 1 down vote accepted

Oh my goodness I got the solution...

The Documentlist contains subfolders and I must recurse the Items in it.

  SPQuery qry = new SPQuery();
            qry.Query = string.Format(@"   <Where><And><Eq><FieldRef Name='{0}' />  <Value Type='Text'>{1}</Value></Eq><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq></And></Where>", FieldNameBusinesArea, businessAreaToFiler);
            qry.IncludeMandatoryColumns = true;
            qry.ViewAttributes = "Scope='RecursiveAll'";

            // get the items
            SPListItemCollection aktenCollection = akten.GetItems(qry);

Now I got the results. Thx alot

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.