4.2

Table Of Contents
8 Define a function to calculate and generate a Date object named timerDate in the scripting pad in the
Scripting tab.
For example, you can create a Date object by implementing the following JavaScript function, in which
the timeout period is a relative delay in milliseconds.
timerDate = new Date();
System.log( "Current date : '" + timerDate + "'" );
timerDate.setTime( timerDate.getTime() + (86400 * 1000) );
System.log( "Timer will expire at '" + timerDate + "'" );
The preceding example JavaScript function defines a Date object that obtains the current date and time by
using the getTime method and adds 86,400,000 milliseconds, or 24 hours. The Scriptable Task element
generates this value as its output parameter.
9 Click Save.
You created a function that calculates and generates a Date object. A Waiting Timer element can receive this
Date object as an input parameter, to suspend a long-running workflow until the date encapsulated in this
object. When the workflow arrives at the Waiting Timer element, it suspends its run and waits for 24 hours
before continuing.
What to do next
You must add a Waiting Timer element to a workflow to implement a long-running workflow that is based
on a timer.
Create a Timer-Based Long-Running Workflow
If you know a workflow will have to wait for a response from an outside source for a predictable time, you
can implement it as a timer-based long-running workflow. A timer-based long-running workflow waits until
a given time and date before resuming.
You implement a workflow as a timer-based long-running workflow by using the Waiting Timer element.
Prerequisites
You must have created a workflow, opened it for editing in the workflow editor, and added some elements to
the workflow schema.
Procedure
1 Drag a Waiting Timer element from the Generic menu to the position in the workflow schema at which
to suspend the workflow's run.
2 Link the Waiting Timer element to the elements that precede and follow it in the workflow schema.
If you implement a scriptable task to calculate the time and date, this element must precede the Waiting
Timer element.
3 Click the Waiting Timer element to show its properties tabs in the bottom half of the Schema tab.
4 Provide a description of the reason for implementing the timer in the Info properties tab.
5 Click the Attributes properties tab.
The timer.date parameter appears in the list of attributes.
Chapter 1 Developing Workflows
VMware, Inc. 57