When to use SharePoint Feature Dependency

Written By: Shishir Bhandari -- 10/27/2010 -- join -- contribute -- (92) comments -- printer friendly version

Rating: Rate --

Categories: Configurations, Features, MOSS 2007, SharePoint 2010, SharePoint Foundation 2010, WSS3

< Prev - 1 | 2 | 3 | 4 | - Next > | Become a paid author


This article deals with the Feature Dependency concept in SharePoint. The article assumes the reader knows how to create a feature. If you want to know more about creating a feature, refer to this msdn article.

In simple terms, Feature Dependency means a feature is dependent on another feature to work. In other words, unless the other feature is activated, the dependent feature won't work.

This article outlines when to use Feature Dependency, how to code Feature Dependency, and what the User Experience is activating this kind of feature.


What is a Feature Dependency?

Example 1: Suppose there are 5 features which deploy different lists to the web and all of these lists are using a lookup pointing to a master data list at the site collection level. The 5 lists won't work unless the master data list exists. So these 5 features are dependent on the feature which deploys the master data list and its lookup at the site collection level. If a user activates the list features first, the lists won't work since the lookup will throw an error. In order to avoid such a condition, we must use "SharePoint - Feature Dependency".

Example 2: A feature which deploys Custom Content Types is dependent on another feature which deploys custom site columns used in that custom content type. Unless the site columns are deployed, the content types won't work. To implement such dependency cases, "SharePoint - Feature Dependency" comes into picture.

When to Use Feature Dependency?

Scenario 1 : (Similar to Example 1 in above section)
If you have to deploy various types of lists in a site, but you don't want to click multiple times for activating its features, you can assemble all the list features in one MAIN feature. When you activate this MAIN feature, it would activate all the list features by itself. Wouldn't that be nice?

Example Out of the box, the TeamCollab feature activation will cause activation of 19 other features deploying different list types. These list types along with their feature IDs are shown in the section below figure 1. SharePoint automatically activates all the features that are mentioned as a dependency in the TeamCollab feature.

Scenario 2 : (Similar to Example 2 in above section)
We have a feature called "Site Content types" which installs content types on activation and the "Site Columns" feature which installs site columns used in the Content type. If we activate the "Site Content types" feature first, it will cause issues since the relevant Site Columns haven't been installed yet.

In such cases, we need to create feature dependency between such features.

< Prev - 1 | 2 | 3 | 4 | - Next >

Learn more about SharePoint

Sponsor Information

Copyright (c) 2010-2017 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | contribute | feedback | about
Some names and products listed are the registered trademarks of their respective owners. |