Loop a flow or subflow
About this task
You can define a flow or subflow that loops a specific number of times or loops until a specific condition is met. This is useful if you need to rerun a group of jobs until you achieve specific results.
In this example, John needs to run a series of three jobs that need to be repeated until the correct data results—an undetermined number of times. John created the following flow called DataRefine:

Process Manager allows you to automatically rerun a flow or subflow whenever a particular work item in the flow has a specific exit code. This allows John to loop DataRefine as many times as required to complete refining the data results. In the script run by the job Examine_data, John sets the exit code of the job to be a particular value, such as 77, until such time as the data refinement is complete. Then the exit code of Examine_data is set to 0. John used the exception handling at the flow level to loop the flow, as follows:

If John requires it, he can use the number of times the
flow is rerun in his job. This information is available through the
built-in variable JS_ITERATION_COUNTER
[flow_name],
where flowname is the name of the flow, without the user name. For
example:
JS_ITERATION_COUNTER
[myflow:subflow]
To loop a flow: