SharePoint custom solutions: Storing extra data in SharePoint

 

When developing SharePoint solutions there is often the need to store extra information at certain levels in SharePoint. In this blog I enumerate some of the possible levels where extra information can be stored:

 

WSS list: just add an extra field, easy!

 

Web: SPWeb object has a property called… properties. This property is of type

Microsoft.SharePoint.Utilities.SPPropertyBag. This property bag is an extension of the .Net framework class System.Collections.Specialized.StringDictionary, a hashtable with the key strongly typed to string. In this property bag you can store any object by name. Don't forget to call the Update method on this SPPropertyBag to persist your modifications to this property bag to the database. Because information is stored persistently to the database, I assume the object stored in the property bag must be serializable.

 

Site: It is sometimes still difficult to differentiate between what is a site and what is a web in SharePoint terms.  From the manual: "The SPSite class represents a collection of sites on a virtual server, including a top-level site and all its subsites." This collection of sites are called the webs. Each SPSite has at least an SPWeb connected to it, you can get this web using the OpenWeb() method. So there is no need to store extra data at the site level, store it in the corresponding web as described above.

 

Area: The Portal area's have a fixed set of extra properties that can be assigned. Have a look at the Bool1..Bool3, DateTime1, Int1..Int3, NText1, NVarChar1..NVarChar4 properties (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/cArea.asp). Use those properties to store extra information, and don't forget to call the Update method after setting those fields! This information is quite restricted, but can be used for fast querying on area's. Each area also has a connected SPWeb accessible through the Web property, where the property bag can be utilized as described above.

 

Area Listing:  The Portal area listings extensibility is patterned along the same lines as the area. Again we have properties Bool1..Bool3, DateTime1, Int1..Int3, NText1, NVarChar1..NVarChar4 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/pAreaListings.asp).

8 Comments

Comments have been disabled for this content.