SharePoint 2010: Using Property Bags to store Metadata

Introductions
For the .Net aaplication Metadata managemernt can be done in a number of ways including App.Config and Web.Config files. But here in case of SharePoint 2010 Apps, we have Property Bag Settings. 
Property bags  can store any metadata as Key-Value pairs such as connection strings, server names, file paths, and other miscellaneous settings needed by your SharePoint application.
Although this feature should be used with caution as improper use of the SPFarm property bag may corrupt the SharePoint configuration database.

The SharePoint Property Bag Settings 2010 includes a hierarchical configuration manager that can safely store and retrieve configuration settings at the following levels: 
  • Farm (SPFarm class)
  • Web application (SPWebApplication class)
  • Site collection (SPSite class)
  • Site (SPWeb class)
  • List (SPList class)

Usage:

To make used of property bags, we require to manually install Propert Bag webpart which is available on the following link:

http://pbs2010.codeplex.com/

After successfully deployment of the webpart in the central admintration -> System Setting, you will see "Custom Settings"
Upon entering the custom settings, we get the property bag and "New Property" link lets us add new properties.


Code Snippet for accessing the values in Property bag programatically:
SPFarm Farm = SPFarm.Local;string colCustomer = Farm.Properties["spCustomerColumn"].ToString();string URL = Farm.Properties["SpSite"].ToString();

Hope this helps,
Cheers

Comments

Popular posts from this blog

SPFx: Develop using SharePoint Framework without Installing all the dependecies.

SharePoint Online: Elevated Permissions....with love

Powershell: Filling up an Existing Excel Sheet with data from SQL Server