There are many ways to get a date or timestamp into a node on the task builder. You can pass it from an answer on a request, or you can send it as a result through a trigger. In this article you will learn the basics of how to use ruby to add it directly from a parameter field in a node in the task builder.
What is the use case for this? Often, task trees are in a deffered or wait status while another process completes, or a person makes a decision. When this is the case, you may want to record the date and time that a tree retarts or continues. One of the easiest ways to do this is to record the date/time when the node is processed. If you need to format this nicely, using ruby in the node is an excellent option.
The most basic way to add a date/time is with the ruby method DateTime.now. Used in a parameter it should appear like this <%=DateTime.now%>. This will give you a very basic time stamp - set to GMT. It will look like this:
You can also format the date/time using the strftime method. It allows you to use parameters to present the date in the format you require. Documentation on the parameters is found here:
Here are a couple of examples with their output:
<%=DateTime.now.strftime("%l:%M%p")%> => 9:37AM
<%=DateTime.now.strftime("%m/%d/%Y")%> => 03/21/2012
One thing to be aware of is your timezone. The date/time is calculated from the timezone of the web server running the task engine. If you need a different time zone, you will need to provide that when either creating your time, or you will need to do some date/time calculations.
Here are some screenshots for illustration:
Parameter field from the node (node creates an entry in the KS_SAMPLE_Incident form)
Summary field with the data created by the node