Wednesday, 4 July 2007

SharePoint 2007: Programmatically add an item/event to a SharePoint 2007 calendar using .NET code

Useful when adding calendar or other events to SharePoint lists via the Lists web service.

http://enterprise-solutions.swits.net/infopath2007/article.php?t=programmatically-add-item-sharepoint-calendar-infopath&c=infopath2007
Things of note:

Lists Web Service
You can update items programatically using the Lists webservice: http://Server_Name/Site_Name/_vti_bin/Lists.asmx

Batch XML

<batch><method id="1" cmd="New"><field name="Title"><field name="Location"><field name="Description"><field name="EventDate"><field name="EndDate"><field name="fAllDayEvent"></method></batch>

Date Formats:
YYYY-MM-dd or YYYY-MM-ddTHH:mm:ssZ.

You can specify whether an event is an All Day Event by setting the value of the fAllDayEvent field to 1 and passing in dates that have the YYYY-MM-dd format.