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:
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
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
Post a Comment