Example: Building a Loop Counter Using Workflow Parameters

A workflow parameter can be used to generate a counter for the number of times a workflow step enters a state.

To build a loop counter using workflow parameters:

  1. From the Workbench shortcut bar, select Configuration > Workflows.

  2. Open a workflow.

    The Workflow window opens.

  3. From the Workflow tab, click Add.

    The Workflow Parameter window opens.

  4. Type the information as listed in the following table.

    Field Name

    Description

    Prompt

    Loop Counter

    Token

    LOOP_COUNTER

    Description

    Stores count

    Default Value

    0

  5. In the Parameters section of the Workflow tab, 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 Creating Execution Workflow Step Sources.

    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.

  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.