While I keep working on migration contents from old SharePoint versions to current versions (2010, Online), I’m discovering new little tricky things on the SharePoint Object Model (primarily .net client object model).

The last tricky thing I discovered is that EndDate field for Event List items cannot be updated for existing items (already created).

When creating an event list item I was updating each field individually and for each field I was updating the item and executing the query:

newItem.Update();
ctxRoot.ExecuteQuery();

While this worked pretty well for most items and its fields, I got stuck by the EndDate field (one of the predefined, mandatory fields for Event items). This field seems to be like a read only field when you try to update it in an existing event item.

What I did is update every field (including the EndDate) before executing the update of the item when I created it for first time.

My update code for the EndDate field looks like this:

ListItem newItem = newList.AddItem(newItemInfo);

//Here other field updates

if (field.Type == FieldType.DateTime && !field.Hidden && fieldValue.Key != “Modified”)
{
newItem[fieldValue.Key] = FormatClientDateTimeString(fieldValue.Value);
}

newItem.Update();
ctxRoot.ExecuteQuery();

Fairly I couldn’t find a good solution for update existing items (my solution is for new items), my work around for existing items is to save all the data of the existing item in an object, then delete the existing object and finally create a new one with the new data.

If you find any better solution to this, I would like to read it in the comments below 5media