SharePoint Developer Support Team Blog

The Official blog of the SharePoint Developer Support Team

HOW TO: Programmatically delete a single instance of a recurring event in a SharePoint calendar

HOW TO: Programmatically delete a single instance of a recurring event in a SharePoint calendar

  • Comments 1
  • Likes

This blog post is a contribution from Kevin Jacob Kurian, an engineer with the SharePoint Developer Support team.

When we edit a single instance of a recurring event, it actually creates a new instance of the event and deletes the old one.  The old instance is deleted by setting certain attributes of that particular instance.  This is per design.

Here’s an example of deleting a single instance of a recurring event:

SPListItem deleting_item = list.Items.Add();
deleting_item["MasterSeriesItemID"] = olditem.ID;
deleting_item["UID"] = olditem[“UID”];
 
// EventType is the attribute that defines that this event is to be deleted
deleting_item["EventType"] = 3;
 
// fRecurrence identifies that the event is a recurring event
deleting_item["fRecurrence"] = 1;
deleting_item["fAllDayEvent"] = olditem["fAllDayEvent"];
deleting_item["EventDate"] = olditem["EventDate"];
deleting_item["EndDate"] = olditem["EndDate"];
 
// Set RecurrenceID this to the date of the event instance you want to delete
deleting_item["RecurrenceID"] = olditem["EventDate"];
 
// the “Deleted:” keyword is required in the Title of the deleting instance
deleting_item["Title"] = "Deleted: " + olditem["Title"].ToString();
deleting_item.Update();
list.Update();

HTH!

Comments
  • the code that you provided is not working, the selected event is not getting deleted.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment