2

I am looking to write a CAML query that returns all folders recursively starting at a certain folder.

CAML Designer has helped me to get this far:

<ViewFields>
      <FieldRef Name='FileRef' />
   </ViewFields>
   <Where>
      <And>
         <Eq>
            <FieldRef Name='ContentType' />
            <Value Type='Computed'>Folder</Value>
         </Eq>
         <Eq>
            <FieldRef Name='FSObjType' />
            <Value Type='Integer'>1</Value>
         </Eq>
      </And>
   </Where>
   <QueryOptions>
      <ViewAttributes Scope='RecursiveAll' />
   </QueryOptions>

This query starts at the root of the list. I want to start one level down in a particular folder. Can someone show me how to do that?

I thought to require that the name of the item contain /startingfolder/, but it seems that I can't but the / in the "contains" specification. How does one specify a string that contains a '/'?

Thanks.

1

You need either camlQuery.set_folderServerRelativeUrl(folderPath); (JSOM) or SPQuery.Folder (Server API). Both respect the "Recursive" attribute.

MSDN references:

0

If you want items in a specific folder you can use FileDirRef column and filter based on it..

  <Eq>
    <FieldRef Name="FileDirRef" /> 
    <Value Type="Text">/folderPath</Value>
 </Eq>
  • I don't want the items in a particular folder. I want everything below a specific folder. – Ira D Aug 27 '14 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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