Friday, July 3, 2009

Site Coloumn As Feature

How To Create a Feature
As a first step you you have to add a subfolder containing a Feature definition(Feature.xml) within the Features setup directory (Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES). Feature.xml file defines the base properties of the Feature and lists elements bound to it. The Feature element is used in a Feature.xml file to define a Feature and to specify the location of assemblies, files, dependencies, or properties that support the Feature

Create a Site Coloumn Feature
1. Create a new folder called "SampleBlogColoumn" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\.

2.Create a new file called features.xml containing:

<Feature Id="F5E3FEE8-1D9B-4b95-848B-7614D638B90D" Title="Sample Bloge Site Columns" xmlns="" Description="Shyju mohan's Sample Site Columns" version="" scope="Site" hidden="FALSE">


<ElementManifest Location="elements.xml">



This feature.xml will describe about our new site column feature.This file should be placed in the folder created in previous step.

3. Create a new file called elements.xml

<?xml version="1.0" encoding="utf8"?>
<Elements xmlns="">
<Field ID ={94EF4E88-A8AE-4b11-8110-DEE7B2CE4D41} Name="PersonName"
SourceID="{9c8a1ac8-fe75-4d7d-87af-e1de3e1b82e6}" StaticName="PersonName" Group="BlogSample"
Type="Text" DisplayName="Person Name"/>
<Field ID ={95EF4E88-A8AE-4b11-8110-DEE7B2CE4D41} Name="Age"
SourceID="{9c8a1ac8-fe75-4d7d-87af-e1de3e1b82e6}" StaticName="Age" Group="BlogSample"
Type="Text" DisplayName="Age"/>
<Field ID ={96EF4E88-A8AE-4b11-8110-DEE7B2CE4D41} Name="Salary"
SourceID="{9c8a1ac8-fe75-4d7d-87af-e1de3e1b82e6}" StaticName="Salary" Group="BlogSample"
Type="Number" DisplayName="Salary"/>

This element.xml will describe each coloumn in our feature.This file should be placed in the folder created in previous step.Now we are ready to deploy our feature.Assumes already know about the tool STSADM (Exe tool runs from the command propmpt).We can use stsadm to deploy our feature

4. Open a command prompt and type the following:

CD C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin

stsadm -o installfeature -file SampleBlogColoumn

Above command will install the feature.Next step is to activate the feature so we can go for command prompt again or sharepoint central administration site to activate the feature.

5.Again in command prompt and type the following:

stsadm -o activatefeature -file SampleBlogColoumn -url http://localhost/

Further Reading Content Type as Feature

Shyju Mohan

No comments: