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:

  1. On the PPM Workbench shortcut bar, click Configuration > Workflows.

  2. Open a workflow.

  3. In the Parameters section Workflow tab, click Add.

  4. In the Workflow Parameter dialog box, complete the following fields:

    1. In the Prompt field, type Loop Counter.

    2. In the Token field, type the token name (for example, LOOP_COUNTER).

    3. In the Description field, you can type a short parameter description.

    4. In the Default Value field, you can specify a default parameter value.

  5. In the Workflow Parameter dialog box, click Add.

  6. Click OK.

  7. From the Workflow tab, click OK.

  8. 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.

  9. 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.