April 26, 2012 7:18:10 AM PDT
Goal: Using JavaScript to Set the Expired Time of An Absolute Timer
Fact: Fujitsu Interstage BPM (Business Process Manager) all versions
Fact: JavaScript
Fact: Evaluate Script Server Action
Fact: Absolute Timer
Fix:
This is a tutorial intended to demonstrate how to set the expired time of an absolute timer of an activity node via Prologue script in Interstage BPM.
1. Define an absolute timer associated with the activity node. Name the timer as "Timer 1".
2. Once timer is defined, BPM automatically created two reserved UDAs.
Locate the UDA that is used to hold the expired time of the timer in milliseconds of long value.
The name of the UDA for absolute timer of an activity node has the following format:
__atmr_<name of timer>_time.
3. To manipulate the value of this UDA, __atmr_<name of timer>_time, via evaluate script action, the following script is used to set the expired time to be three minutes after the timer is activated.
// obtain the current date value
var curDate = new Packages.java.util.Date();
// obtain the current time stamp in milliseconds.
var curDateInMillisec = curDate.getTime();
// To make this absolute timer to
// expire 3 minutes after the node is activated.
// 3 minutes = 180000 milliseconds.
var expiredTimeInMillisec = curDateInMillisec + 180000;
// save this expired time value into the UDA.
uda.__atmr_Timer1_time = expiredTimeInMillisec;
4. To see a working sample, refer to the attachment. Import the xpdl file. The sample template consists of one activity node with one absolute timer defined. The expired time of the timer is set via the prologue action, specifically an evaluate script action. The timer is set to expire three minutes after the activity is activated.
Launch a new process from this template. Go to process details page to see the state of the timer and its expiration time. You should expect the expired time to be three minutes after the work item is created.
Note: To manipulate the expired time of an absolute timer, the timer cannot be in running state. In other words, you cannot modify the expired time of a timer that is in running state.
Author: C.Y. Chen
Attachment: DemoOfAbsoluteTimerManipulation.zip