I have two SP2013 workflows that I built in SP Designer. They both do pretty much the same thing, but for different fields.
In both of them I set a DateTime workflow variable to Today
.
One of them gets the date and the time, the other one only gets the date (and shows a time of 12:00AM).
How can I ensure that I capture the current time as well as the date?
I've read a bunch of posts that use a trick where the workflow updates something on the item, and then immediately grabs the CurrentItem:Modified
value. I really don't want to do that.
I read another post that suggested getting the time that the workflow started form the workflow context, which should be reasonably close to "now". That would be acceptable to me but I don't see anything like a "time" or "started" option available in the workflow context menu.
More details:
These are two workflows on the same list, each set up to operate on different fields. The underlying field type that they are saving to is Note (plain text), but I am using CSR to create a kind of custom field type. The purpose of the field is to expose a button in the View and Edit forms whereby a user can click the button to send a specific email notification. I wire up the button to start the workflow via the REST API. The workflow sends the email, and then saves a time stamp of when the notification was sent in the note field. Multiple time stamps are allowed and are pipe separated. Then, back in the UI, the rendering code reads all the time stamps and displays a list of the times the notification email was sent, next to the button.
Originally I was trying to save the time stamps as ISO formatted, and then render them in the UI using Date.toLocaleString()
, but I noticed that included seconds, and I though it didn't look good and was more detail than was really needed, so I changed the workflow to save the time stamps as ShortDate ShortTime
, so it's pretty much pre-formatted text at that point and no need to re-parse it through a Date
object on the client side.
The first dates are still in ISO format because I changed up how I store and show the values. But, as you can see, the first field captures an accurate time, and the second one does not.
Date
object and pass that to the workflow as an initiation parameter. That way both workflows consistently get the correct date and time of when they run.