I Love the SiteData.asmx Web Service
There are a whole slew of SharePoint web services, but today I decided to try out the SiteData.asmx one, in a data view web part (the GetListCollection operation in particular). As I’ve mentioned before, I’m not a developer, so in a lot of cases, the data view web part (DVWP) has become my best friend.
In various SharePoint discussion threads, message boards, and Q &A panels, there have been many people who have asked the following question: How can I just display a list of my site’s document libraries in a web part? There are varying reasons for this, such as just wanting to automatically have them all listed together somewhere other than the quick launch. Good news! It looks like there’s a way to do this, using the SiteData web service and the GetListCollection operation.
- Create a blank web part page, and open it up in SharePoint Designer. Click on “Click here to insert a Web Part”. This is really just to make sure that you insert this web part into a web part zone, and not some random spot on the page.
- On the <Data View> menu at the top, click <Insert Data View>
- In the Data Source Library pane on the right side, expand “XML Web Services” and click on Connect to a Web Service.
- Now, on the Data Source Properties screen, I always do this first, just so I don’t forget. Go to the <Login> tab, and select Use Windows Authentication. Of course, if you have Kerberos or some other security scenario, you’re welcome to pick something else.
- Now, go back over to the <Source> tab. Copy the URL of your site to the clipboard, and paste it into the Service Description Location box. Then, after it, type:
- Click <Connect Now>
- Leave the default Data command as Select, and for the Operation, choose GetListCollection.
As far as the Port goes, if someone knows the difference between Soap and Soap12, please let me know.
- Click OK
- Click the drop-down box on the name of the new web service (SiteData on…) and click Show Data.
- Now the Data Source Details task pane appears on the right, which lists all of the fields in the data source. Select the following fields: Title, Description
- Click Insert Selected Fields as, and choose Multiple Item View. Now, you see a list of all lists and libraries on your site, along with their descriptions, similar to what you see on your View All Site Content page.
- Now, before we filter it to just show document libraries, I want to show you a couple of other things. Click inside your list, and click the little chevron at the top right of the list, which will show you a new menu.
- Click Edit Columns, and add the following columns: Inherited Security, Internal Name
See how cool! Those of you that use the URL of the list settings page to obtain the list GUID may be relieved to see this method of getting it. Also, wow, now we can see what lists and libraries are inheriting permission from the parent or not!
- Just as a side note for fun, you can always click on the data in the first row of the InheritedSecurity column, and choose <Data View>, <Conditional Formatting> and create a new condition so that if the list doesn’t inherit permission, the text is red and in all caps:
- Now, getting back to the main objective here… to display a list of document libraries.
- Click inside your list, and click the little chevron at the top right of the list. Click the word Filter:
- The filter needs to be BaseTemplate equals DocumentLibrary. Click OK.
- Let’s change the way that this list is displayed. On that same list fly-out menu (or whatever the official name is), click Data View Properties…, and go to the <Layout> tab. Choose the bulleted list of titles, and click OK.
- Now, the title of the library needs to be a link to the library itself. Click to select the title of the first document library. Click the little chevron next to it.
- In the Format As field, select Hyperlink. Click Yes at the prompt.
- Clear the Address field, and click the Function box next to it. Chose the DefaultViewURL field. Clear the Text To Display box, and choose the Title field for that one. Click OK.
There’s your pretty little list of all of the document libraries in the site! Save the web part page, and this is what it will look like in the browser. Export the web part, save it, and then you can delete the web part page that you created it in. Now, import this nugget into whatever page it needs to be displayed on.
As I showed him all of the coolness that I discovered in web services, my (developer) co-worker said “I hate to burst your bubble, but developers already know about what’s available in the API. This is all pretty basic stuff”.
I know, I know. None of this is new to developers, but I’m not a developer, so I think it’s great. It’s all new to me. 😉
Also, watch my associated 5 minute video:
Don’t let your dev ruin a perfectly good post. I am a dev and I appreciate this post along with your My Very Own Dashboard post: Good stuff (:
Laura: Pay no attention to your co-worker — this is terrific!!!!
This is excellent! I was asked this very thing not 2 days ago by a non dev web designer and was going to suggest fudging around with CQWP but will teach them this method instead.
Hi Laura, i havent tried it yet but it sounds terrific. Nice Job done.
Very cool stuff!
Thank you very much for giving such an information about webservices, i knew about this before , but now its more clear , awesome post .keep it up.
So, is there any way to do this for a library so that it will display the list items and whether they inherit permissions?
Hi Laura, Good post! Have you tried to use the sitedata web service with the GetListItems method? I can get most everything else to return data, but not this one … and it’s the one I need. Thanks, Dave.
David, Have you tried lists.asmx?
Hey Laura, I have used this in several places and it has been a lifesaver, thank you soooo much! As a side thought, do you know if there is any reason why certain lists or libraries wouldn’t show up in the dashboard? Security trimming or maybe they set the results to not show in search? Just curious, thanks again for the amazing results!
Hey Laura, You are great. I love you. You’ve saved my life from my manager several times. The tasks he gave me seemed impossible but you make it sound so easy. I would love to have lunch with you someday, really you are AWESOME.
bhorner, No, I’ve never seen that happen, I guess it would be because of security trimming. Ivan, You buyin?
This is what i am looking for long time and ur post gave answer to it. I have used sitedata webservice for site data but never thoguth that it would have list data as well. Thanks a lot for a very great & excellent post U really deserve kuddos 🙂
This is great.
Would you have an idea on how to show a listing of all lists/libraries of a site and it sub-sites?
In order not to have to import the webpart in every sub-site.
There’s an out of box web part (when publishing features are enabled) called site directory or something, which will do this.
Great post, you saved my day!!
What a blast from the past (SP 2007) – I was doing a migration from a location’s old web servers & this was a golden post to save me time to confirm I had covered al my security bases.
thanks a bunch!
Awesome, I’m glad this one is still so helpful after all these years!
Pingback: Your Very Own Permissions Dashboard | @WonderLaura