Reputation: 338
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
Adding reference article
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
Upvotes: 1
Views: 752
Reputation: 338
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>
Upvotes: 1
Reputation: 830
Try
Recursive
for the scope of ViewAttributes
<ViewAttributes Scope='Recursive'/>
Upvotes: 0
Reputation: 830
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.
Upvotes: 1