The standard calendar list in SharePoint has several fields that are sealed. That means we cannot make any mofifications to these fields using the web interface. This short description shows how to create a new feature and a list template to create a modified calendar list. In this example I will change default value of the field ‘All day event’ to ‘true’.

Open Visual Studio and create a new project to create a class library. In this example this project is named ‘MyCalendar’. When the project is created, you can close the file ‘Class1.cs’.

In the project create the folders ‘TEMPLATE\FEATURES\MyCalendar’.

Open an Explorer an navigate to ‘C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\EventsList’. This is the directory for the standard calendar list. Select all elements from this folder and drag the content into the MyCalendar-folder in the Visual Studio-project.

Open the file ‘feature.xml’ and modify the attributes

  • ID
  • Title
  • Description

Additionally add the node ‘ElementFile’ in the ElementManifests-node, as shown in the picture.

Open the Folder ‘ListTemplates’ and open the file ‘Events.xml’. Change the value in the Type-attribute to a value higher than 10000, but keep in mind that the type needs to be unique in the farm. Also change the values for the attributes ‘DisplayName’ and ‘Description’.

Open the Folder ‘Events’ and open the file ‘schema.xml’. Find the Field-node for the field ‘fAllDayEvent’. Add a node ‘Default’ to the Field-node and set the value to ‘1’.

Now we need to deploy our new feature. Create a new folder named ‘Solution’ to your project in Visual Studio. Add a new text file to this folder and name it ‘package.ddf’. This should be the content of the file:

In the Solution-folder create a second file. It’s an xml-file named ‘manifest.xml’. Remember, the value for the attribute ‘SolutionId’ needs to be unique within the farm.

In the Solution-folder we have two files now:

To build and deploy our solution, we simply use STSADM. To install the solution, create a batch file named ‘Install.bat’ in your project and use this content in the batch file:

To uninstall the solution we use STSADM, too. Create a batch file named ‘Uninstall.bat’ in your project and put this content into the file:

Now open a Command Prompt and change the working directory to your project. Run ‘Install.bat’. If there are no errors, the solution-file (MyCalendar.wsp) is built and deployed to the SharePoint-farm.

Now use the SharePoint Management Shell to activate the feature in the desired site:

Open the SharePoint-site, where the feature is activated and create a new list. Here you should see the ‘My Calendar’-template. Enter a valid name and create the list.

When you add a new item to the list based on your calendar template, you will see that the checkbox for the ‘All day events’ is checked by default.

This is the best way to modify elements in SharePoint. Using these steps we do not modify any OOTB-items from SharePoint, so we are supported by Microsoft any time. Another benefit: when you add additional SharePoint-machines to your farm, these modifications are deployed automatically.

Advertisements