1

I wrote a java program that uses SharePoint's Lists web service.
Right now, this is my CAML Query :

<Query>
    <Where>
      <Contains>
         <FieldRef Name='FileDirRef'/><Value Type='Lookup'>SubFolder1</Value>
      </Contains>
    </Where>
</Query>

and this is my CAML Query Options :

<QueryOptions>
   <ViewAttributes Scope='RecursiveAll' />
   <OptimizeFor>FolderUrls</OptimizeFor>
</QueryOptions>

This is what my root folder looks like :

enter image description here

And my program returns all File3.txt, SubFolder2 and File4.txt
What should I do in order to only get the contents of SubFolder1 : File3.txt AND SubFolder2 ?

Also, Is there a way to place myself on a folder other than root ?

  • I think you need to check query.FolderServerRelativeUrl chk sharepoint.stackexchange.com/questions/59216/… and answers.flyppdevportal.com/categories/sharepoint2010/… – user13408 Sep 14 '16 at 17:38
  • Thanks @Neel , I've been looking down that path the hole night but there's no way of using FolderServerRelativeUrl under Java environment and you can't insert it directly into the CAML Query file either. – Ali Sep 15 '16 at 8:23
  • yes you are right FolderServerRelativeUrl is for sharepoint api only. – user13408 Sep 15 '16 at 9:44
1

I finally found the answer I was looking for thanks to this Blog.
I deleted the CAML Query settings :

<Query>
    <Where>
      <Contains>
         <FieldRef Name='FileDirRef'/><Value Type='Lookup'>SubFolder1</Value>
      </Contains>
    </Where>
</Query>

and added this line to my CAML Query Options file :

<Folder>http://MySharePointServer/Root/SubFolder1</Folder>

And changed the Scope to All instead of RecursiveAll so it would only bring items directly under SubFolder1.

So now this is my Final CAML Query Options File :

<QueryOptions>

    <Folder>http://MySharePointServer/Root/SubFolder1</Folder>  
    <IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>     
    <ViewAttributes Scope="All"/>   
    <DateInUtc>TRUE</DateInUtc>     
</QueryOptions>


PS : you have to specify the hole URL to the SubFile. you cannot use RelativeUrl for this option.

  • Do you know if this works with a library over the item threshold limit? – Webfort Jan 3 '17 at 10:17
  • No sorry @Webfort I didn't try that out – Ali Jan 4 '17 at 10:52

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.