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

Add a user interaction element to the workflow schema.

Procedure

  1. Log in to the Automation Orchestrator Client.
  2. Navigate to Library > Workflows, and select your workflow.
  3. Select the Schema tab.
  4. Place a Scriptable task element before the workflow element that requires the relative Date object for its timeout.date variable.
  5. Enter a name and description for the scripted workflow element.
  6. Create a Date variable for the Scriptable task element.
    1. Under Inputs/Outputs, create a variable.
    2. Name the variable timerDate.
    3. Select Date from the list of variable types.
    4. Leave the value text box empty, because a scripted function provides this value.
    5. Click Save.
  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. To finish editing your workflow, click Save.

Results

You created a function that calculates a time and date relative to the current time and date and generates a Date object. A User interaction element can receive this Date object as an input parameter to set the timeout period until which it waits for input from the user. When the workflow arrives at the User Interaction element, it suspends its run and waits either until the user provides the required information, or for 24 hours before it times out.

What to do next

You must bind the Date object to the User interaction element's timeout.date variable. See Set the timeout.date Variable to a Relative Date.