Monday, June 15, 2009

Understanding Feature activation dependencies

Hi All,

When you create the feature, it can also include the dependencies. Let’s say, we have one feature that is dependent on the other feature, that means when we activate one feature, it actually requires the other feature already been activated, at that time we can use this feature dependencies.

A very good example of this is TeamCollab feature which activates many other features automatically. It creates several list templates and makes it available for the site.

Let me give you a very simple example of Feature Dependencies.

<Feature
Id={GUID}
Title={title}
Description={Description}
Version={version}
Hidden={value}
Scope={value}
xmlns={namespace} />

<ActivationDependencies>

<ActivationDependency FeatureId = {dependent Feature GUID}/>

</ActivationDependencies>


That means the feature inside the ActivationDependency must be activated before the main feature gets activated.

If the main feature is A and inside ActivationDependency we write feature B, then activating Feature A first activates feature B and then activates feature A.

Note that Feature B must be installed first at specific scope.

Other very important thing to note here is you must have to define feature B (Feature that goes inside ActivationDependency) as Hidden, otherwise SharePoint will throw error saying that the dependant feature is not enabled.

That's it. your job is done.

2 comments:

Anonymous said...

Just so people are aware, these xml files are case sensitive! The attribute 'FeatureID' should infact be 'FeatureId', that is to say, it should have a lowercase 'd'. Sorry to be pedantic, but Sharepoint consistancy is a bit of a joke in terms of how case is applied to certain attributes.

Andy

SharePoint Kings said...

Andy,

You are absolutely correct.
it should be "FeatureId" not "FeatureID" its just a typo mistake as direct xml is not allowed in blog to copy.

Thanks for pointing.

Sharepoint Kings Team




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com