Example: Using Workflow Parameters to Build a Loop Counter
You can use a workflow parameter that generates a counter to keep track of the number of times a workflow step enters a state.
To build a loop counter:
-
On the PPM Workbench shortcut bar, click Configuration > Workflows.
-
Open a workflow.
-
In the Parameters section Workflow tab, click Add.
-
In the Workflow Parameter dialog box, complete the following fields:
-
In the Prompt field, type Loop Counter.
-
In the Token field, type the token name (for example, LOOP_COUNTER).
-
In the Description field, you can type a short parameter description.
-
In the Default Value field, you can specify a default parameter value.
-
-
In the Workflow Parameter dialog box, click Add.
-
Click OK.
-
From the Workflow tab, click OK.
-
Create a new immediate SQL execution workflow step.
For details on how to create an SQL execution workflow step, see Create execution workflow step sources.
There are two key concepts to note about the new step definition.
-
The result of the SQL execution workflow step returns the result LOOP_COUNTER + 1. This return value is linked back into the parameter when the workflow step is generated on a workflow.
-
A validation for a numeric text field is used. This allows you to use <=, <, >=, and > comparisons in transitions off this step.
The following shows the Execution window for the SQL execution workflow step.
-
-
Add the workflow step to a workflow and choose the new workflow parameter Loop Counter.
By choosing Loop Count, the workflow engine is told to assign the result of "select loop counter val + 1" from dual back into the loop counter parameter.
You can now add transitions to and from the new loop counter step. For example, you add the loop counter each time an execution fails. If the execution fails three times, a notification is sent to the user. If the execution fails five times, management is notified.