What is feature stapling?

Definition: In SharePoint, Feature is used to group SharePoint project items for easy deployment.

Feature can be activated and de-activated based on requirement and accordingly project items added in the feature, will be activated and de-activated from the scope it is deployed.

Create a Feature:

  • Go to Visual Studio
  • Create a SharePoint empty project >> Select – Deploy as a farm solution
  • Open the Feature file and add below feature properties.
  • Title: Enter title of the feature
  • Description: Enter the text which describes the feature
  • Scope: Specify the scope of the feature
  • Items in the Solution: Here you can find all the items that can be added in feature
  • Items in the Feature: Here you can find all the items that you are adding as part of feature

Below are the scopes of a Feature. A Feature can be deployed at below mentioned levels.

  • Farm Level:
  • Web Application Level:
  • Site Collection Level:
  • Site Level:

Definition: There may be situation when your feature is dependent on any other feature for functionality or data. In this situation, you can mark that other feature as dependency for your feature.

You can add other feature in your solution as dependency so that before activating your feature you can make sure that other feature is activated.

Add Dependency:

  • Open Project >> Open Feature in design mode
  • Expand the Feature Activation Dependencies node. Click on Add button
  • In the Add Feature Activation Dependencies dialog box, choose the Add a dependency on features in the solution option, choose the title of the feature that you want to add as a dependency, and then choose the Add button.
  • Add more than one feature by choosing multiple titles while pressing Ctrl

Add Custom Dependency:

  • Open Project >> Open Feature in design mode
  • Expand the Feature Activation Dependencies node. Click on Add button.
  • In the Add Feature Activation Dependencies dialog box, choose the Add a custom dependency option,
  • In Feature ID text box, enter the GUID of the feature that you want to mark as dependency.

Definition: Feature stapling is the process by which you can add new functionalities to the existing site definition. So after feature stapling, when you create a new site using that site definition, the functionalities in the feature will be automatically available in the new site.

- You will need to create a farm solution for this implementation.

- Remember, you don’t need to change definition files (onet.xml) for this. You are just deploying one solution which will work according to the feature-scope selected.

- The feature will be activated by default only on the new sites, so you will have to manually activate the feature on old sites.

- As part of solution, you will need two features.

(1) The feature which will be activated by default or the feature with the new functionalities

(2) The feature which will be used to staple the first feature to the site definition.

You can go through step-by-step process for implementing Feature stapling in SharePoint

We value your feedback:

Page URL:

Name:

 

Email:

 
 

Feedback:

 

© 2019 Code SharePoint