get documents from parent site and all sub sites

Apr 21, 2015 at 2:14 PM
I need to pull all documents from the parent site and all sub sites, is something like this possible with SPServices?

I currenlty have a CEWP doing this, however, I want to format the UI of the web part and a few other things, and if I can do this via code it'll be better for us in the long run.

thanks
Coordinator
Apr 29, 2015 at 12:57 PM
Absolutely. You can spin through all of the sites with GetAllSubWebCollection (or one of the other Webs operations) and read from each Document Library.

A better option might be to use the Search service or a Content Search Web Part, depending on what version of SharePoint you're on.

I'm not sure what you mean by "I currenlty have a CEWP doing this". Do you mean you currently have it hard-wired?

M.
Apr 30, 2015 at 4:27 PM
I have a content query web part and I have it going through the parent and sub sites within it looking at the document libraries to pull out all of the documents. However, I added an option to for the users to say [show on home page] yes/no, if yes is selected then the document will show on the home page of the site, if no is selected then it will only show on the home page of the sub site. The filters in the content query web part is not picking up the new column to filter on, plus I want to change the format on how it shows, so I figured I'd see if the SPServices can get all of the docs out of all doc libraries
Coordinator
Apr 30, 2015 at 4:40 PM
Ah, ok. You said CEWP above, not CQWP.

In any case, absolutely possible.

M.
Apr 30, 2015 at 5:45 PM
yeah that was a typo on my part.


how would i get all of the doc libraries within the site and all its sub sites? I've used SPServices to pull from one list in the parent site, but I need to pull from the parent and all its subs?
Coordinator
Apr 30, 2015 at 5:48 PM
As I mentioned above, use one of the Webs operations to get all the sites to loop through and the GetLists to get the Document Libraries in each site.

But the Search service is likely to be more efficient if you can tolerate the indexing lag.

M.
Apr 30, 2015 at 5:55 PM
Edited Apr 30, 2015 at 6:38 PM
I can't use the search service for this, it has to be in real time and there is a lag in the search.

I'm able to use the GetAllSubWebCollection, however, the issue i'm running into is that it's getting me all sub sites for the collection, where I need all sub sites for a sub site.

so for example

if site == hr, i need to get all of the HR sub sites