WSS Dev: A simple feature – Type Custom Action

So what was a feature? Let’s see if I can come up with a good explanation. I think it is here explanations often is too vaugue.
A feature is zero or more elements. Elements can be list and/or what a lists consists of like content type, list items and fields, but also other kind of site content. See the list below.
A feature must be activated. If the feature has zero elements then it is only code in the activation/deactivation eventhandler that makes up the feature, but that code is optional.
With that definition a feature is a plug-in to sharepoint, that adds more than the standard elements.

In the below table the features are printed from a sample WSS site collection. The elements are printed from MSDN.

Features Elements
Many lists are implemented as features. Features must be activated in the context of a Farm, a Web app, a Site Collection or a Site. Features are configured in feature.xml files which includes zero or more elements. One feature can be made of elements.
DocumentLibrary Content Type
WebPageLibrary Content Type Binding
NoCodeWorkflowLibrary Control
PictureLibrary Custom Action //menu item
DataSourceLibrary Custom Action Group
XmlFormLibrary Document Converter
AnnouncementsList Feature/Site Template Association
LinksList Field
TasksList Hide Custom Action
DiscussionsList List Instance
IssuesList List Template
WorkflowHistoryList Module
SurveysList Receiver
GridList Workflow

If I want to make a simple feature then which elements should it contain?

I like that question because on this HowTo you are presented with a feature with an element of type Custom Action. And what the he.. is that? Three WSS words meaning nothing to a newbie. A better word for the Custom Action element could be MenuItem. Custom Action adds an item to a menu.
With the above table you get a bigger picture. A feature is like Lego. You build blocks like an AnnouncementsList from smaller elements.

When you examine AnnouncementsList inside the feature directory %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES you find:

Feature.xml: – Notice a link to an xml file containing elements.

 <Feature Id="00BFEA71-D1CE-42de-9C63-A44004CE0104" Title="$Resources:core,announcementslistFeatureTitle;" 
	Description="$Resources:core,announcementslistFeatureDesc;" Version="" 
	Scope="Web" Hidden="TRUE" DefaultResourceFile="core" xmlns="">  
	<ElementManifests>   <ElementManifest Location="ListTemplates\Announcements.xml"/>  </ElementManifests>

ListTemplates\Announcements.xml: – Notice the type of an included element is ListTemplate.

 <Elements xmlns="">
	<ListTemplate Name="announce" Type="104" BaseType="0" OnQuickLaunch="TRUE" SecurityBits="11" Sequence="320"
	DisplayName="$Resources:core,announceList;" Description="$Resources:core,announceList_Desc;"  Image="/_layouts/images/itann.gif"/>

But the long story is put in Announce\schema.xml in where you find a long xml script code. I certainly hope this is generated code – it seems too long and complex to handwrite (1706 lines!).

This didn’t make us more wiser than to show some of the pieces needed to make a template for an announcement list. But it should have broadened our vision of what a feature is.

So now we should go on with the

MSDN HowTo Create a simple feature – Type Custom Action

So what is the idea of following that article? Well I can add some comments that I otherwise has to look else where to find.

The project is made without WSPBuilder. With WSPBuilder you get a template as a starting point and deployment facilities are included in the project menu. See this article.

The project includes following files and folders:

The \Template\feature\ folders is where the files in them should be deployed in the 12Hive.
The .snk key file is not needed here since we don’t have code to install in the GAC, but a feature will often have some code.

The feature.xml:

  Id="" //create a new GUID here
  Scope="Farm | WebApplication | Web | Site" How many sites will use this feature at the same time?
  Title="" //Name of the feature project
  Description="bla - bla" //Optional
  Hidden="TRUE | FALSE" //Optional. false if the feature should be activated manually, true if the feature should be activated by script
  ImageUrl="" //Optional - An image for the feature to be activated in the ??? menu
  ReceiverAssembly="" //Optional - use it if you overwrite events for activating/deactivatting the feature
  ReceiverClass="" //Optional - use it if you overwrite events for activating/deactivatting the feature
  Version="" //Optional
  SolutionId = "" //Optional
  Creator="" //Optional
  ActivateOnDefault = "TRUE" | "FALSE" //Optional. Only for Farm or WebApplication.
  AlwaysForceInstall = "TRUE" | "FALSE" //Optional
  AutoActivateInCentralAdmin = "TRUE" | "FALSE" //Optional. Not for Farm. 
  RequireResources = "TRUE" | "FALSE" //Otional - see Msdn
  DefaultResourceFile =  "" //Optional
	Title="Title for Feature-CustomAction-UrlActionTemplate"
	Description="This is a Feature template"
	SolutionId = "Feature-CustomAction-UrlActionTemplate"
    <ElementManifest Location="elements.xml" />

In the feature file for this feature there are a few things to notice:

  • The scope is web. Then the feature should be activated in each site under Site Settings – Site Features.
    If the scope was site, then the feature should be activated in a site collection under Site Settings – Site Collection Features.
  • There are elements included in this feature in the file elements.xml.
  • There is no eventhandler code for activate/deactivate, since ReceiverAssembly and ReceiverClass is not used.

The elements.xml:

<Elements xmlns="">
	<!-- - Element types - CustomAction Defs - CustomAction Element - Location - Rights
	<!--<CustomAction //Scope all 4
	  Title = "" //Req
	  Location = "EditControlBlock | //item menu
				DisplayFormToolbar | //
				EditFormToolbar | //
				NewFormToolbar | //
				ViewToolbar | //
				Microsoft.SharePoint.StandardMenu | //Misc menues - incl SiteActions
				Microsoft.SharePoint.Administration.ApplicationCreated | //SPCA - App Created Page
				Microsoft.SharePoint.Administration.ApplicationManagement | //SPCA - Adm Mgmt Page
				Microsoft.SharePoint.Administration.Operations | //SPCA - Operations Page
				Microsoft.SharePoint.ContentTypeSettings | //Site Collection Content Type page
				Microsoft.SharePoint.ContentTypeTemplateSettings | //List Content Type page
				Microsoft.SharePoint.Create | //Create page
				Microsoft.SharePoint.GroupsPage | //site collection People and Groups page
				Microsoft.SharePoint.ListEdit | //Customize page
				Microsoft.SharePoint.ListEdit.DocumentLibrary | //Customize page 
				Microsoft.SharePoint.PeoplePage | //People and Groups page
				Microsoft.SharePoint.SiteSettings | //Site Settings page
				Microsoft.SharePoint.User | //Web site Permissions page
				Microsoft.SharePoint.Workflows" //Workflow pages
	  GroupId = "" //Optional. See
	  Id = "" //Optional. See
	  Sequence = "Integer" //Optional
	  Description = "" //Optional
	  ImageUrl = "" //Optional
	  ContentTypeId = "" //Optional - Don't use this parm. User RegistrationId with RegistrationType=ContentType
	  ControlAssembly = "" //Optional
	  ControlClass = "" //Optional
	  ControlSrc = "" //Optional
	  RegistrationType = "ContentType | FileType | List | ProgId" //Optional
	  RegistrationId = "" //Optional
	  RequireSiteAdministrator = "TRUE" //Optional
	  Rights = "" //Optional 
	  ShowInLists = "TRUE" //Optional
	  ShowInReadOnlyContentTypes = "TRUE" //Optional
	  ShowInSealedContentTypes = "TRUE" //Optional
    Title="Goto MS"
    Id="View List Toolbar CustActLink"
    Description="bla - bla"
    ImageUrl="~site/_layouts/images/next.gif" >
      <UrlAction Url=""/>

Things to notice in the elements file:

  • There is only one element of type CustomAction. CustomAction is a menu item.
  • The menu item should be placed on the Location=ViewToolbar. This is a toolbar you see when you are in view mode and look at lists.
  • Left out is GroupId, which is needed for some locations. See
  • The category of lists this feature applies to is generic lists (RegistrationType=”List“)
  • The type of list this feature applies to is AnnouncementsLists (RegistrationId=”104“).
    I guess the sharepoint team are not good a thinking object oriented since we should be presented with database ID’s.
  • The menuitem also has an image – a kind of right pointing arrow. The link to the image includes a link to the site collection (~site) and a relative path to the virtual directory for application pages (_layouts).
  • The title is the value shown on the menubar
  • The description i a yellow pop-up

RegistrationIds of type List: or or

select tp_Title, tp_ServerTemplate 
from Wss_Content..AllLists 
order by tp_Title 

RegistrationIds of type ContentType:

RegistrationIds of type FileType: “docx” etc.


SET HIVE12="%programfiles%\common files\microsoft shared\web server extensions\12\Template"
SET STSADM="%programfiles%\common files\microsoft shared\web server extensions\12\bin\stsadm"
SET GACUTIL="%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil"
SET PROJNAME=Feature-CustomAction-UrlActionTemplate
SET TARGETSITE=http://spvm/

REM Install into GAC
%GACUTIL% -if bin\debug\%PROJNAME%.dll

REM Copy to TEMPLATE folder
xcopy /e /y TEMPLATE\* %HIVE12%

REM Install and activate feature
%STSADM% -o installfeature -filename  %PROJNAME%\feature.xml -force
%STSADM% -o activatefeature -filename %PROJNAME%\feature.xml -url %TARGETSITE%


You don’t have to install into GAC, since no code is used in this feature, but just leave it here, so you can use it, when you have some code included.

You will notice that the feature is already activated:

And here is the menuitem in place:


SET HIVE12="%programfiles%\common files\microsoft shared\web server extensions\12\Template"
SET STSADM="%programfiles%\common files\microsoft shared\web server extensions\12\bin\stsadm"
SET GACUTIL="%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil"
SET PROJNAME=Feature-CustomAction-UrlActionTemplate
SET TARGETSITE=http://spvm/
SET PROJSN="%PROJNAME%,Version=, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"

REM UnInstall and deactivate feature
%STSADM% -o deactivatefeature -filename %PROJNAME%\feature.xml -url %TARGETSITE% -force
%STSADM% -o uninstallfeature -filename %PROJNAME%\feature.xml -force


REM uninstall from GAC

The End


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: