I created a site WF to send status reports as an HTML table. I'm stuck because it seems like the date type variable cannot be null/empty.
My workflow has to loop through the items in the list and right them on the email/table.
- I'm able to query the list and get results
- Everything works well if all the date columns have data in it.
Seems' like I can't use collection operations (get) in an empty column either if the column doesn't have any date. It works if I have at least one item in the column date has data.
Every effort to work around if date is empty fails with different errors or results.
- Variable with "blank" adds a 1/1/0001 date to the variable - I need this to be blank if there's not date.
- Collection operations with get, or clear in a For Each loop gives me an error: "Data type returned from the collection is incompatible with the variable to store the result in."
- I tried a Run if, Set a Condition and a state machine if count of items in the column is zero or field is empty
- Also tried to compare if results = 1/1/0001 then set a variable to blank ...
Nothing seems to work on date null/empty/blank.
I'm not able to add a Filter action into the WF, it just doesn't do add.
Has anyone have experienced this issue? Have a workaround? Solution? Suggestion?
p.s. on WF 2013.
Solved! Go to Solution.
Hi Monica Pope ,
To set a Date field to blank follow these steps:
1. Use Convert value action.
2. Input = 1/1/0001, store it in varBlankDate of Date and Time type.
Now you can compare this field within your Query action. Hope it helps.
"To set a date field to blank". Just to clarify, I'm starting with blank value (column is empty).
So, if I use the Convert 1/1/0001 to ... variable and compare that on my query, the WF still errors when I compare it within the For Each.
Can you please expand on your solution? How would I use this in the WF? Thanks!
Based on Kapil's reply I found a workaround that basically circumvents the date data type.
1) I'm working with 3 text variables
- Line of text with default value of 1/1/0001 ("StartDate")
- Line of text with empty default value ("BlankDate")
- Line of text to store the date as string ("DateAsText") - result of this variable will be printed on the email report
2) Created a condition to inside the For Each action to compare the item value (date column) with variable with default value of 1/1/0001
3) If yes: Set "DateAsText" as "BlankDate"; if no: Set "DateAsText" as item value