Iterating multiple blocks
We can use Iterate Tasks
in action flow, to execute multiple set of repeated actions on array of data. Below are the various ways in which you can iterate multiple blocks
Setting up Iterate Tasks
- Go to the
Events
of any control/screen, and selectadd action
. - Click to add an action or connector. Search for
Iterate Tasks
inOn-Screen Actions
under theUtility
group. - Enter
Count/Array
indicating number of times the iteration will be run fromSTART to END
. You can selectcontrol
orkeyword
from aUse Keywords
dropdown list, consisting of all the in-use controls, keywords and data queries available presently in your app. - Click on
Finish
and then the iterate task will be added for the selected control.
MAX 100
iterations can be performed.
OUTPUT Keywords of Iterate Tasks
The outputs from the Iterate Tasks
, represented by the placeholder {{ITERATETASKS}}, can be referenced in other action blocks inside Iterate Tasks
, where ITERATETASKS
is name of the Iterate Tasks.
Output | Description |
---|---|
{{ITERATETASKS.INDEX}} | It can be used to get the current index of the item of the data given for iteration task. It starts from 0 and goes up to length-1 of the data. |
{{ITERATETASKS.VALUE}} | It will have the object/string of the current index of the data given for iteration task. If you have an iterated array of objects, then it will return the entire object of current index. For eg. If its an array of json objects, then you can get product_id for current json object using {{ITERATETASKS.VALUE["product_id"]}} . |
Configuring iteration of a task
After setting up the number of iterations, the next is to set up the actions
in the iteration loop which need to be repeated. You can simply add other tasks or server-side actions as well as perform nested iterations between ITERATE TASKS START
and ITERATE TASKS END
.
- You will get Single value when you use
OUTPUT
variable of one action block in subsequent action block withinITERATE TASKS
- You will get Array of value when you use
OUTPUT
variable of one action block in subsequent action block outsideITERATE TASKS
Iterating Server-side actions
You can also add server-side action
tasks to the iterate tasks. Each Iteration leg run parallelly
and are mutually exclusive, so you can not use output variables
of one task from first iteration
into another task of second iteration leg
.
Nested Iteration
You can even add multiple iterations in a nested form. There might be cases where data is available in a multi-dimensional array of objects, requiring iteration in each object. In that case you can nest the iterations one inside another along with distinctive actions and tasks.
- Branch
- End Action Flow
- Confirm
- Popup