TwitterLinkedInBlog

Monday, January 18, 2010

SP2007 - Event Handler AfterProperties DateTime

...
using Microsoft.SharePoint.Utilities
...

// THIS WORKS:
DateTime taskDueDate = Convert.ToDateTime(properties.ListItem[TASK_DUE_DATE_INTERNAL_FIELD_NAME]);

// THIS DOES NOT WORK:
// DateTime taskDueDateAfter = Convert.ToDateTime(properties.AfterProperties[TASK_DUE_DATE_INTERNAL_FIELD_NAME]);

// USE THIS INSTEAD:
string taskDueDateAfterString = properties.AfterProperties[TASK_DUE_DATE_INTERNAL_FIELD_NAME].ToString();
DateTime taskDueDateAfter = SPUtility.CreateDateTimeFromISO8601DateTimeString(taskDueDateAfterString);

No comments: