Loops
Automatiqal v0.4+
Task can be executed multiple times by using loop
property. For example if the task is to create 3 tags then the following task can be written:
1 2 3 4 5 6 7 8 |
|
Automatiqal
will loop through the values, defined in the loop
property and will run the same operation but replacing {{ item }}
with the currently looped value.
Values
loop
property can contain either:
- array of mixed
string
,numbers
orboolean
- array of objects in format
key: value
, wherevalue
can be mix ofstring
,number
orboolean
Examples:
1 2 3 4 |
|
1 2 3 4 |
|
The following is NOT allowed since it will mix primitive values and objects:
1 2 3 4 |
|
Accessing values
{{ item }}
- will be replaced with the current loop value{{ index }}
- will be replaced with the current index value (First element will be1
){{ item.<key> }}
- when using objects in theloop
property it will be replaced with the<key>
value of the currently looped element. For example:
1 2 3 4 5 6 7 8 9 10 11 |
|
While looping Automatiqal
will use the value for the name
property to replace item.name
with.
Context
The loop syntax can be used anywhere in the task. And if object with multiple keys are used then different keys can be used for different purpose.
For example - if we have to publish multiple apps and each app should be published in a different stream then our task can look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Task results
Since tasks with a loop
are ran multiple times then the result of these will be the combined result from all the runs.
In our example above if we want to perform another task, that us using the result from Publish apps
as a source, then this task will be performed on both published apps.
Concurrency
By default the loops are executed in sequence. There is a task option that can overwrite this behavior and run the loops in parallel:
1 2 3 4 5 6 7 8 9 10 |
|
When loopParallel
options is explicitly set to true
then the loops will be ran in parallel.