WSS 3.0 Workflow - How to set a field value to null

Tag: sharepoint , wss Author: lanshu8208 Date: 2009-08-03

WSS 3.0

I have a List that contains a text field, a check-box, and a Date field. When the check-box is ticked I want to set the date field to the current date, and when a check-box is un-ticked I want to set the Date field to blank (or null, I don't care which just as long as it appears blank).

I have created a Custom Workflow using Sharepoint Designer which correctly handles the first situation - and inserts the current date as required. But I am unable to create a Workflow action that will set a Date field to null or blank. By default the Date field is not displaying a value (which is what I want) so I know it must be possible to reset it to be the same.

Anyone have any ideas?

One suggestion to improve the accepted solution: You do not have to put your EmptyDate into your own list, just create another one for general Empty Values purpose. Create a special list EmptyValues, create a field named EmptyDate within that list and the anytime you need it, do this:... Set Variable:MyVariable to EmptyValues:EmptyDate
Designer allows you to create and reference blank date "Initiation Form Parameters". That is, create a blank date initiation field and then set your field to it when needed to clear the date. nothingbutsharepoint.com/sites/eusp/Pages/…

Best Answer

So, this definitely falls in the "Workaround" or "Last Resort" category but it works.

  1. Create a new Date column in your list called EmptyDate (Default Value must be None)
  2. Use the Set Field in Current Item activity to set your Date field to be EmptyDate.

This may work if you use content types and can hide the EmptyDate column so that it can't be filled in.

comments:

@Kit Thank you. I have to admit that I came up with the same 'workaround' this afternoon - but I obviously screwed up somewhere because it did not work. However, I just tried it again and it works well - so thanks for encouraging me to go back and try again. It is a 'workaround' as you suggest and it would be interesting to know if there is a cleaner way to do this. In the meantime, yours is a good answer.
If you want to go the custom route, you can probably write a simple custom Workflow Action that just returns Null to store in a variable.