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:
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);
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.
Latest posts by Guillermo Bas (see all)
- SharePoint 2013 Public Beta has been released - July 17, 2012
- Exception when accessing https sites from SharePoint soap web services - July 3, 2012
- EndDate Field cannot be updated programmatically on existing Event List items - June 21, 2012