Monday, April 12, 2010

Um, why is my SharePoint workflow clearing out date fields?

A few months ago I was writing configuring a very simple workflow using Nintex Workflow 2007.  The workflow ran on a document library, did some work when a document was uploaded, then updated the metadata on the document.  While testing what was supposed to be a "very simple workflow" I discovered that when I updated the metadata (a non-date field) on the document via workflow, any date fields on the document would be cleared out.  My initial reaction was that something was awry with my worfklow...and I went down the path of troubleshooting.  After many hours, I was finally led to this little gem by my BFF Google, which describes my issue perfectly:

You manipulate custom properties for documents in a document library. When you use code to read or to write the SPListItem.Properties  property bag, data loss for date fields occurs. The data loss occurs only when you call the SPListItem.Update()/SystemUpdate  after the property bag read operation or write operation.

Ah-ha!  This sounds pretty darn accurate. 

...see, the workflow remained "very simple" after all.  ;)

Your welcome!