1
1
The perfect solution for creating powerful yet inexpensive business solutions by integrating data from multiple SharePoint lists. Enesys RS Data Extension lets you leverage all the power of Microsoft SQL Server Reporting Services with your SharePoint Data.

Knowledge Base and Samples

Retrieving Property Bags

This article shows you how to retrieve SharePoint Property Bags values using the xmlQuery statement.

Introduction

The xmlQuery statement allows you to retrieve data from an XML file, enhancing the possibilities to retrieve data from almost any source, including SharePoint data that can’t be retrieved using Web Services. Therefore, all you need is an ASPX page that will retrieve those properties and serialize them in XML.

Property Bags are metadata kept in several kind of elements in a SharePoint environment, you can have Property Bags in Farms, Servers, Web Applications, Site Collections, Sites and Lists.

Here are some usage examples of these properties:

  • You may want to tag all your sites with a Boolean indicating whether to display this site in a report. Therefore, you would create a Site Template that has a property set to true by default, and changing its value for a specific site whenever you want to hide it from the results.
  • You may have a generic report that displays data for a site using a parameter and each site has a default value for a property. This default value can be kept in Property Bags and used in your report.
  • You may want to tag an element with an extern ID that would allow you to join SharePoint data with your extern data.

SharePoint Property Bag Settings is a tool available in CodePlex that allows you to easily manage Property Bags in your SharePoint environment.

Installation

We have developed a solution that will deploy an ASPX pages in the LAYOUTS folder of your SharePoint server. The solution is available for download on the Download page of our web site.

To deploy the solution on your server, you can execute the following script (you may need to replace “http://localhost” by your web application URL):

          
          @setlocal
          @set PATH=%commonprogramfiles%\Microsoft Shared\web server extensions\12\BIN
          stsadm.exe -o addsolution -filename ERSDETools.wsp
          stsadm.exe -o deploysolution -name ERSDETools.wsp -immediate -allowGacDeployment -url http://localhost
          @pause
          @endlocal
          
        

The ASPX page is available through the “_layouts/Enesys” URL for any site, example: http://spsdemo/_layouts/Enesys/PropertyBag.aspx

Using the PropertyBag.aspx page

The page allows you to retrieve Property Bag from a Farm, a Server, a Web Application, a Site Collection, a Site or a List. Depending on the element you want to retrieve, you must provide some parameters to the page.

Farm Property Bags

To query the Farm properties, the scope parameter must be set to “Farm”, or must be null (its default value is Farm). The page will retrieve the metadata for the local farm.
Here are some examples that you can use to retrieve Farm properties of the current farm:

  • http://spsdemo/_layouts/Enesys/PropertyBag.aspx?scope=Farm

Server Property Bags

To query the Server properties, the scope parameter must be set to “Server”, and the server parameter must be set to the server name (default value is the current server).
Here are some examples of URLs to retrieve Server properties. All these pages retrieve Property Bag for the spsdemo server:

  • http://spsdemo/_layouts/Enesys/PropertyBag.aspx?scope=Server
  • http://other-server-in-the-same-farm/_layouts/Enesys/PropertyBag.aspx?scope=Server&server=spsdemo

Web Application Property Bags

Web Application properties are retrieved when the scope parameter is set to “WebApplication”, and the webApp parameter is set to the web application URL (default value is the current web application).
Here are some examples of queries to retrieve Web Application properties. All these pages retrieve Property Bag for the http://spsdemo web application:

  • http://spsdemo/_layouts/Enesys/PropertyBag.aspx?scope=WebApplication

Site Collection Property Bags

Site Collection properties are retrieved when the scope parameter is set to “SiteCollection” and the site parameter is set to the site collection URL, its default value is the current site collection.
Here are some examples of URLs to retrieve Site Collection properties for the “/sites/ersdedemo/” site collection:

  • http://spsdemo/sites/ersdedemo/_layouts/Enesys/PropertyBag.aspx?scope=SiteCollection

 

Site Property Bags

Site properties are retrieved when the scope parameter is set to “Site”, the site parameter is set to the site collection URL and the web parameter is set to the site URL, their default values are the current site collection and the current site.
The following links are some examples of how to retrieve Site properties for the “/sites/ersdedemo/demosubsite01” site:

  • http://spsdemo/sites/ersdedemo/demosubsite01/_layouts/Enesys/PropertyBag.aspx?scope=Site

List Property Bags

There is no real “List” Property Bags, they are linked to a specific Folder. However, we can use these Folder properties to keep List properties. To retrieve these properties, the scope parameter must be set to “List”, the site parameter must be set to the site collection URL (default value is the current site collection), the web parameter must be set to the site URL (default value is the current site) and the list parameter have to be set to the folder architecture to access the list.

Employees' folder name

The following links retrieve List properties for the “Employees” list (“Lists/Employees” folder) in the “/sites/ersdedemo/” site:

  • http://spsdemo/sites/ersdedemo/_layouts/Enesys/PropertyBag.aspx?scope=List&list=Lists/Employees

Querying the XML file

Once you have the correct link, you can retrieve the metadata using the xmlQuery statement.

  • Launch Enesys SharePoint Query Builder
  • Connect to your SharePoint server
  • Add a xmlQuery statement
  • Change its “type” property to “Url”
  • Enter the URL to the file in the “URL to XML file” property
  • Test the query by clicking on the “Execute” button.

The following query will return all the metadata available in the Property Bags of the “List/Employees” folder located in "http://spsdemo/sites/ersdedemo/" site.

The metadata stored in the Property Bags of the