1

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?!

3
  • SharePoint 365 supports CAML. Have you try to do the same query with a tool like a caml designer: biwug.be Commented Feb 6, 2013 at 11:33
  • 1
    Just to double-check: Are you querying a text field?
    – Stu Pegg
    Commented Feb 6, 2013 at 11:54
  • Hi this field ist a normal textfield. And the value already exists.
    – Sascha
    Commented Feb 6, 2013 at 12:11

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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