Some xml elements in Element.xml file in WSS 3.0:
1. Root element: Elements. It contains a Id attribute, which is a guid to uniquely identify this element.
2. Receivers element: This element is inside Elements. It contains ListTemplateId attribute which specifies what type of list will be attached to list item event handler. For example, a value of 101 means that the event handler will be attached to all document libraries.
3. Receiver element: This element is inside Receivers element. It contains several sub elements in it to define the class to receive list item event. A sample configure is like this:
<receiver>
<name>DigiDoc signature check event
<type>ItemUpdated
<sequencenumber>5000
<assembly>wssDigiDoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=44b3223b8da05605
<class>wssDigiDoc.ddocEventHandler
</>
- Name: A descriptive name
- Type: The event type that this receiver class will handle. The possible values are: ItemAdd, ItemUpdate, ItemDelete...
- SequenceNumber: It specifies the event firing order, if multiple event handlers are associated with the feature
- Assembly: Fully qualified assembly name
- Class: Class in the assembly that handles item level event
<customaction id="DigiDocSettings" groupid="SiteAdministration" location="Microsoft.SharePoint.SiteSettings" rights="ManageWeb" sequence="30" title="DigiDoc feature settings">
<urlaction url="_layouts/ddocsetting.aspx"></urlaction>
</customaction>
- Id: The unique identifier for the custom action
- GroupId: See Location attribute.
- Location: This combined with GroupId defines where to put the action link. The possible value for Location are:
- Microsoft.SharePoint.SiteSettings, the site settings page. The GroupId then defines the which section in site settings page the action link should be put under. GroupId SiteAdministration will put the action link under "Site Administration" section on site settings page; GroupId SiteCollectionAdministration will put the action link under "Site Collection Administration" section; GroupId UsersAndPermissions refers to Users and Permissions section, etc.
- Microsoft.SharePoint.StandarMenu. The SharePoint standard menu. The GroupId can be: SiteActions, which means to put the action link in SiteActions menu on top right of page; SettingsMenu, which means the list's settings menu; ActionsMenu, which means the list's actions menu; NewMenu, which means the list's New menu; PersonalActions which means "Welcome (username)" menu on top of page.
- Microsoft.SharePoint.Administration.Operations: Operations tab in WSS central administration. The GroupId is GUID referencing the Id defined in CustomActionGroup. The Title attribute determines the text appearing as the link.
- Microsoft.SharePoint.Administration.ApplicationManagement: Application tabl in WSS central administration. The GroupId is GUID referencing the Id defined in CustomActionGroup. The Title attribute determines the text appearing as the link.
- EditControlBlock: The context menu when you move your mouse on list item. When the location is set to this value, you need to also to set RegistrationType and RegistrationId attribute to specify what type of list to apply the custom action.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomActionGroup
Id="BDDBB947-CBC6-47f7-B57A-6C8BEB0E19D7"
Location="Microsoft.SharePoint.Administration.Operations"
Title="Utilities"
Sequence="1000"/>
<CustomAction
Id="E57ECD33-91FD-4fc3-A4E8-E1B932178CB4"
GroupId="BDDBB947-CBC6-47f7-B57A-6C8BEB0E19D7"
Location="Microsoft.SharePoint.Administration.Operations"
Sequence="10"
Title="View Unified Logging Service"
Description="Displays Unified Logging Service (ULS) logs.">
<UrlAction Url="_admin/ULSLogViewer.aspx"/>
</CustomAction>
</Elements>
- RegistrationType: Defines what type of data this custom action applying to. The possible value could be: List, ContentType, FileType and ProgId.
- RegistrationId: When the RegistrationType is List, this RegistrationId specifies the types of list, for example, 101 mean document library, 104 means announcement; when the RegistrationType is FileType, the RegistrationId is the file name extension.
- Rights: Specifies a set of rights that the user must have in order for the link to be visible, for example, "ViewListItems,ManageAlerts". If not specified, then the action always appears in the list of actions. To specify multiple rights, separate the values by using commas. The set of rights are grouped logically according to AND logic, which means that a user must have all the specified rights to see an action. For a list of possible values, see Microsoft.SharePoint.SPBasePermissions.
- Sequence: Determine the display order of the action
6. File: This element provisions the aspx file into SharePoint site. The Url attribute references the physical file deployed. The Name attribute defines the file name used by user. Type attribute specifies if this file is customizable. For example:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Url="Pages">
<File Url="ViewLog.aspx" Name=ViewClientLog.aspx Type="Ghostable" />
<Module>
</Elements>
The above element.xml will provision ViewLog.aspx file into SharePoint site. User should be able to access the file using http://
7. Field: The Field element defines the site columns that can be used in creating new column in list. The field definition schema is much same as the definition in list schema.xml file.
<field name="Digital Signers" id="{6251682B-A4A6-4cc4-BCE4-7C5247546CCD}" type="Note" title="Digital Signers" displayname="Digital Signers" description="Names of people who have signed this document digitally. Automatically updated" readonly="FALSE" showineditform="FALSE" showinfiledlg="FALSE" showinnewform="FALSE">To use the field defined in element.xml file, use the following code snippet:
</field>
if (SPContext.Current.Web.Fields.ContainsField("MyFieldTitle"))
{
SPField field = web.Fields.GetField("MyFieldTitle");
if (!item.Fields.ContainsField(field.Title))
{
item.Fields.Add(field);
}
}
Comments