5.5

Table Of Contents
n
Add some elements to the workflow schema.
Procedure
1 Drag a Scriptable task element from the Generic menu to the schema of a workflow, before the element
that requires the relative Date object for its timeout.date attribute.
2
Click the Edit icon ( ) of the Scriptable task element in the workflow schema.
3 Provide a name and description for the scripted workflow element in the Info properties tab.
4
Click the OUT properties tab, and click the Bind to workflow parameter/attribute icon ( ).
5 Click Create parameter/attribute in workflow to create a workflow attribute.
a Name the attribute timerDate.
b Select Date from the list of attribute types.
c Select Create workflow ATTRIBUTE with the same name.
d Leave the attribute value set to Not set, because a scripted function will provide this value.
e Click OK.
6 Click the Scripting tab for the scripted workflow element.
7 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.
8 Click Close.
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.
Developing with VMware vCenter Orchestrator
64 VMware, Inc.