Looping a flow or a subflow
To loop a flow or subflow, you define exception handlers and exit codes for looping in the Flow Attributes. You then define in the Completion Attributes to determine the flow state according to the exit code of the last failed work item or the last successful work item.
About this task
You can define a flow or subflow that loops until a specific condition is met, such as the exit code of a work item in the flow. This is useful to rerun a group of jobs until you achieve specific results.
By default, an exit code of 0 indicates success. Any other exit code indicates failure, unless you define other non-zero success exit codes in the work item.
You can define that the flow get its exit code from the last finished work item if the flow is successful, or the last failed work item if the flow failed.
You want the flow to rerun until the exit code of the last job Examine_Data is 0.
You also want the flow exit code to inherit the exit code of the last successful work item if the flow was successful or the last failed work item if the flow failed.
In Flow Editor, select
The Flow Attributes dialog is displayed.
- Select the Exception Handling tab and click Add.
Define your conditions.
In the following example, we defined that the flow is to rerun until the job Examine Data has an exit code of 0. The maximum number of times it can rerun is 30:
- Click OK.
To have the flow inherit the exit code of the last successful work item for a successful flow
or the last failed work item for a failed flow, define the flow's Completion Attributes.
and select as shown to have the flow inherit the exit code of the last work item that
succeeded or failed.
- Select and select as shown to have the flow inherit the exit code of the last work item that succeeded or failed.
to save your changes.
If your flow is inserted in another flow, the subflow icon changes to indicate that this subflow will loop, as follows:Note:
The flow you define here will always loop under the specified circumstances, even when embedded in another flow as a subflow.
Any work item that depends on the DataRefine subflow cannot run until the looping completes.