4.1

Table Of Contents
(Optional) Calculate a Relative Timeout for User Interactions
You can calculate in a Date object a relative time and date at which a user interaction times out.
You can set an absolute time and date in a Date object. When the time on the given date arrives, the request
for a user interaction times out. Alternatively, you can create a workflow element that calculates and generates
a relative Date object according to a function that you define. For example, you can create a relative Date object
that adds 24 hours to the current time.
Prerequisites
n
Open a workflow for editing in the workflow editor.
n
Add a user interaction element to the workflow schema.
n
Set the security.group attribute for the user interaction.
Procedure
1 Drag a Scriptable Task element from the Generic menu to the schema of a workflow, above the element
that requires the relative Date object for its timeout.date attribute.
2 Link the Scriptable Task element to the elements that precede and follow it in the workflow schema.
3 Click the Scriptable Task element to show its properties tabs in the bottom half of the Schema tab.
4 Provide a name and description for the scripted workflow element in the Info properties tab.
5 Right-click in the OUT properties tab, and select Bind to workflow parameter/attribute.
6 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.
7 Click the Scripting tab for the scripted workflow element.
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.
Chapter 2 Developing Workflows
VMware, Inc. 45