You can calculate in a Date object a relative time and date at which a user interaction times out.
About this task
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.
Open a workflow for editing in the workflow editor.
Add a user interaction element to the workflow schema.
Set the security.group attribute for the user interaction.
- 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.
- Click the Edit icon () of the Scriptable task element in the workflow schema.
- Provide a name and description for the scripted workflow element in the Info properties tab.
- Click the OUT properties tab, and click the Bind to workflow parameter/attribute icon ().
- Click Create parameter/attribute in workflow to create a workflow attribute.
- Name the attribute timerDate.
- Select Date from the list of attribute types.
- Select Create workflow ATTRIBUTE with the same name.
- Leave the attribute value set to Not set, because a scripted function will provide this value.
- Click OK.
- Click the Scripting tab for the scripted workflow element.
- Define a function to calculate and generate a Date object named timerDate in the scripting pad in the Scripting tab.
timerDate = new Date(); System.log( "Current date : '" + timerDate + "'" ); timerDate.setTime( timerDate.getTime() + (86400 * 1000) ); System.log( "Timer will expire at '" + timerDate + "'" );
- Click Close.
- Click Save.
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 parameter. See Set the timeout.date Attribute to a Relative Date.