Wednesday, March 25, 2009

Activating multiple features in one shot

Scenario:
You want to activate multiple features in one shot.

Solution:
I hacked this solution from out-of-box TeamCollab feature. The TeamCollab feature is an interesting feature because it uses a technique known as feature dependency. Feature dependency enables you to package several features in one feature and activate them all by activating the containing feature. Below is the example of the technique.

Code:

< ?xml version=”1.0” encoding=”utf-8”? >
< Feature Id=”NewGUID”
Title=”BundleFeature”
Description=”This is bundle feature”
ImageUrl=”FeatureLogo.gif”
ImageUrlAltText=””
Scope=”Web”
DefaultResourceFile=”core”
xmlsn=”http://schemas.microsoft.com/sharepoint/” >
< ActivationDependencies >

< !-- Feature 1 -- >
< ActivationDependency FeatureId=”Feature1_GUID” / >

< !-- Feature 2 -- >
< ActivationDependency FeatureId=”Feature2_GUID” / >

< /ActivationDependencies >
< /Feature >

0 comments: