Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>
                  <Eq>
                     <FieldRef Name='Gesch_x00e4_ftsbereich' />
                     <Value Type='Text'>FHC</Value>
                  </Eq>
               </Where>";
            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: biwug.be –  Salvatore Di Fazio Feb 6 '13 at 11:33
1  
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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.