Adding a Do While step
You can use a Do While task to sequentially perform a list of tasks as long as a condition is true. The list of tasks is performed first and then the condition is checked.
To add a Do While step:
- Locate the Do While icon in the API Flow Modeler.
- Drag and drop the icon into the modeler.
-
On the Properties tab, specify this
information:
- Name
- Specify a name for the Do While step.
- Description
- Specify a description for the Do While step.
-
On the Do While Parameters tab,
specify the parameters for the Do While step.
A parameter can be anything that must be referenced in the Do While condition.
A parameter can be any static value, or it can be a reference to an input/output parameter that has been defined in any previous tasks.
-
On the Conditions tab, specify the
conditions for the Do While step.
There are some points of attention:
- You must define the Do-While condition expression with Javascript (Nashorn).
- Do While parameters are referenced as
$.doWhileParameter
.For example:
if ($.doWhileParameter > 100) true; else false
. - Do While activities output can be used in expressions to break the loop.
For example, if there is an activity name 'Activity', you can use an expression similar to '
if ($.Activity != null) true; else false
'. Iteration
is a reserved keyword that returns the current iteration value.The first iteration value starts from 1.
Note: These are the Do While loop limitations:- Do While loop breaks after the hard limit of 100 iterations in a loop, if you intentionally try to loop infinite times.
- Do While has input and output size limitation of 10MB per node/activity. If Do While output is greater than 10MB, then the API Flow fails. Request and Response payload size for individual API task must be less than 10 MB.
- Consider the time out limit of 5 minutes for the whole API flow, so even if there are less than 100 loops, if the processing takes more that 5 minutes, gateway will timeout. In these cases it is better to use the asynchronous mode which has a much higher time limit of 2 hours.