Try OpenEdge Now
skip to main content
BP Server Developer's Guide
Workstep template management : Working with workstep template states
 

Working with workstep template states

Figure 15 shows the state transitions of a workstep.
Figure 15. Workstep state transitions
Typically, during the creation of a process instance, the workstep is in the created or inactive state. Before activating a workstep, its skip condition is evaluated. If the skip condition is "true", then the workstep execution is skipped and the next workstep gets activated. If the skip condition is "false", then the workstep is activated.
During the activation of the workstep, first the precondition is evaluated in case it exists. If the precondition evaluation returns "false", then the workstep goes to the suspended mode. If the precondition evaluation returns "true", then the preJavaScript is evaluated.
If the evaluation of pre-JavaScript fails, and if the compensatory action is specified, then the process instance is rolled back. If the evaluation of pre-JavaScript fails, and there is no compensatory action specified, then the workstep is suspended or stays suspended. After suspension, the resumption of the worksteps starts from the place where it was suspended. If the evaluation of pre-JavaScript succeeds, then the workstep is executed.
During the completion of the workstep, the post-JavaScript is evaluated first. If the evaluation of the post-JavaScript fails, and if the compensatory action is specified, then the process instance is rolled back. If the evaluation of post-JavaScript fails, and there is no compensatory action specified, then the workstep is suspended, or stays suspended. After suspension, the resumption of the worksteps starts from the place where it was suspended.
When a workstep is completed, its loop condition is evaluated. If the loop condition is "true", then the same workstep is activated again and the skip condition for that workstep is evaluated. If the loop condition evaluates to "false", then the next workstep is evaluated.
You can use JavaScript to embed customized business logic into Start, Activity, Subprocess, and Adapter worksteps. Using JavaScript in a workstep is helpful because:
*It executes as an Adapter workstep, without a need to write a Java program.
*It manipulates dataslots within a workstep, without a need to write an adapter.
*It performs JavaScript's regular expression, searching function and pattern matches, as well as using its math library feature to run complex calculations on dataslot values.
If a workstep has both skip and loop conditions, then skip condition is evaluated first before activating the workstep. If the skip condition is "true", then the workstep is skipped and the next workstep is activated without evaluating the loop condition. If the skip condition is "false", then the workstep is activated. When it is completed, the loop condition is evaluated. If the loop condition is "true", then BP Server evaluates the skip condition and repeats these steps. If the loop condition is "false", then BP Server executes the next workstep.
If a workstep is in a loop whose condition is always "true", then that workstep is executed in a never-ending loop. This degrades the performance of the BP Server and EJB servers. To avoid this, you can set the bpserver.ws.max.ActivationCount parameter in the bpserver.conf file to specify the maximum number of times a workstep can be executed. By default it is set to 500. After reaching this number, the workstep is suspended in the next iteration. To resume such a workstep, you must increase the bpserver.ws.max.ActivationCount parameter and reload the bpserver.conf file.
For the connector worksteps (for example, an OR join or a DECISION workstep), if the loopcounter exceeds the maximum limit, then only a warning is logged in the bpserver.log file.
The following APIs help to retrieve the information about the skip and loop conditions.
*public void getSkipCondition()
Helps in retrieving the skip condition related to this workstep.
*public void getLoopCondition()
Helps in retrieving the loop condition related to this workstep.
*public void getLoopConditionCounterDSName()
Helps in retrieving the name of the dataslot being used as the loop condition counter and its value.
* Using PreJavaScript
* Using Post-JavaScript
* Using compensatory JavaScript code
* Using reactivate workStep