1

This is my function why I don't get the subfolders although I'm using recursive ALL option.

I don't even obtain 1-level subfolders I only get the main files and folders, I'm sure I've something wrong in soap request but I can't figure it out.

I've used the same request as this question

Function getResults(url, xmlDoc, spreturnattribute)

    request = "<?xml version='1.0' encoding='utf-8'?>" & _
            "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:soap1='http://schemas.microsoft.com/sharepoint/soap/'>" & _
            " <soap:Header/>" & _
             " <soap:Body>" & _
              "  <soap1:GetListItems>" & _
                "  <soap1:listName>Documents</soap1:listName>" & _
                     "<QueryOptions>" & _
                     "<IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>" & _
                      "<ViewAttributes Scope='RecursiveAll'/>" & _
                         "<DateInUtc>TRUE</DateInUtc>" & _
                    "</QueryOptions>" & _
                "</soap1:GetListItems>" & _
                  "</soap:Body>" & _
                "</soap:Envelope>"


    With CreateObject("Microsoft.XMLHTTP")
        .Open "Get", url, False, Null, Null
        .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
        .setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems"
        .send request



        xmlDoc.setProperty "SelectionLanguage", "XPath"
        xmlDoc.async = False
        xmlDoc.validateOnParse = False
        xmlDoc.resolveExternals = False
        xmlDoc.setProperty "SelectionNamespaces", "xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:namespace='http://schemas.microsoft.com/sharepoint/soap/' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'"
        xmlDoc.LoadXML (.responseText)

        Dim strQuery: strQuery = ".//z:row"

        Set colItem = xmlDoc.SelectNodes(strQuery)

        For Each objItem In colItem
        Debug.Print objItem.Attributes.getNamedItem("ows_LinkFilename").Text
        For Each queryNode In objItem.ChildNodes
          Debug.Print queryNode.Attributes.getNamedItem("ows_LinkFilename").Text
        Next
        Next

    End With

End Function

Edit1

Adding reference article

Edit2

may that due to security issue on the site ? or does setting xmldoc properties cause that? I'm not very good at VBA but it's an easy script and I wonder why it's not working and FYI my sharepoint is 2013

Community
  • 1
  • 1
user690069
  • 330
  • 4
  • 13
  • What _do_ you get? Anything at all? Have you looked at the response? What's in `.responseText`? – John Saunders Jun 10 '15 at 05:39
  • 1
    Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders Jun 10 '15 at 05:48
  • I've just noticed the 2nd part of ur question , .responseText contains the request text . There're already retrieved data which means that there's no errors in the syntax but may I have to organize it ?! – user690069 Jun 10 '15 at 05:52
  • I think you mean it contains the response XML from SharePoint? And that the response XML does not contain the subfolders. – John Saunders Jun 10 '15 at 05:53
  • yeah I mean response text of my request (the result ) not the request – user690069 Jun 10 '15 at 05:55

3 Answers3

1

maybe you need to specify the "rowLimit" parameter for your query.

You can set a specific number

<rowLimit>5000</rowLimit>

or get all items with

<rowLimit>0</rowLimit>

rowLimit is case-sensitive.

Sylvain Gantois
  • 779
  • 1
  • 12
  • 28
1

After alot of trials I've removed all extra unused tags and just checked that link on msdn and updated my caml by adding another tag queryoptions as follows which solves my problem:

     <?xml version="1.0" encoding="utf-8"?>
            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
            <soap:Body>
            <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <listName>listname</listName>
            <FieldRef Name="FSObjType" /><Value Type="int">1</Value>
            <rowLimit>0</rowLimit>
            <queryOptions><QueryOptions>   <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
            <ViewAttributes Scope="RecursiveAll"></ViewAttributes></QueryOptions></queryOptions>
            </GetListItems>
            </soap:Body>
            </soap:Envelope>
user690069
  • 330
  • 4
  • 13
0

Try

Recursive

for the scope of ViewAttributes

<ViewAttributes Scope='Recursive'/>
Sylvain Gantois
  • 779
  • 1
  • 12
  • 28