I recently came across a requirement on a customer project to set a Date field within a SharePoint List item to empty/blank/null – however you think of it – during a SharePoint Designer Workflow if a certain condition was met. I already had my workflow in place and running, so I figured the client request would only take a few minutes: add a “Set Field in Current Item” action to my workflow, choose my Date field, plug in an empty value (or a space if need be), and be done.
And then I had one of those “Ugh, SharePoint!?” moments…
As it turns out, you cannot use the “Set Field in Current Item” action to blank out a date field. No problem I thought, I’ll just trick SharePoint. I’ll create a workflow variable, use the string builder to make it empty, then set my Date field to the variable. But no, bested again. L
I turned to Bing and ran through a couple more attempts – one suggestion was to create a second Date field the user never sees, leave it blank for all time, and “copy” that value into the Date field I wanted blank, but this seemed like overkill. In the end, I paired two suggestions from similar use cases to get the following solution, which has been deployed and working within the customer’s Production environment for more than a month without a single hiccup:
- Create a Workflow Variable named “Empty Date”
- Use the Dynamic String Builder to set “Empty Date” to 1/01/0001
- Use the Set Field in Current Item action to set your Date field to the Workflow Variable “Empty Date”
I’ll defer to the SharePoint Product Team as to why the date January 1, 0001, somehow equates to no date, or even why it doesn’t work if you just try to set the Date field to that value directly, but this combination of a Workflow Variable and that value did the trick. Chalk it up to just another one of those SharePoint things!