One of the more advanced features Cloudpipes supports is pipeline execution flow control. It allows you to implement logical conditions in the form of if-then-else blocks, loop over lists of items (for-each) and even forcibly stop the execution of a pipeline.
These are the basic building blocks of any computer program and they give you the ultimate power and flexibility in designing and building pipelines.
Adding a flow control statement to a pipeline¶
Note: The very first pipe slot in a pipeline will not have these.
Clicking on this icon will insert a logical condition block in your pipeline.
There are three key entities to pay attention to :
(1) - Condition block. A condition is a statement that evaluates to either true or false.
(2) - Pipe(s) that will execute when the condition is true.
(3) - Pipe(s) that will execute when the condition is false.
Clicking on the blue “plus” button (Add Filter) allows you to select the fields you want from what pipes before the if-then-else block export.
In the next drop-down you need to select the test you want to apply to the selected field. Tests available will vary based on the type of field you are testing.
Finally enter the value to test against. In the example here the block reads as:
if card’s name starts with ‘Project Test’
In the cases where more complex logic is needed you can also use the provided AND and OR button to add filters to the condition of the block.
After you have specified the logical condition it’s time to specify what should happen if that condition is met – it evaluates to true. This means adding pipes to the THEN and ELSE branches. Pipes that you put in the THEN will execute if the logical condition is met (it evaluates to true). On the other hand, pipes that you add to the ELSE section will be executed only when the logical condition evaluates to false (is not true).
As an example - let’s say that for the cases when the card’s name does start with “Project Test” we want to move the cards to another list and for the cards with names that do not start with the given string - delete the cards.
There is no limitation on adding just one pipe in these blocks. You can add as many as needed and also you can have more conditional blocks, loops and stop blocks.
Iterating over lists¶
Clicking on this icon will insert a for-each block in your pipeline. Usually you’ll want to do this after pipes that export a list of items in their outputs. Many of the “Search ...” pipes are examples of such.
Using the for for-each construct you will be able to execute pipes for each item in the list that is being iterated over. In this example we are Searching (listing) Trello Cards.
In the DO section you add the pipes that you want to have executed for each item. Like :
In our example we want to add a label to all the cards in the list, so we simply add an “Add Label” pipe, and select the label we want added in the pipe configuration.
Just like with the if-then-else blocks, there is no limitation on adding just one pipe in the DO section. You can add as many as needed and also you can have more conditional blocks, loops and stop blocks.
Stop Pipeline Execution¶
The Stop block terminates pipeline execution once that block is reached.
For example if we have a Trello Card that belongs to a list that is not to be modified and given after the if-then-else block there are pipes that would modify the card, we can implement a pipeline like the above. The stop block will terminate pipeline execution as soon as it’s reached and no further pipes will be run.
Flow control blocks are very powerful and flexible features of Cloudpipes. They allow you to implement logical conditions (if-then-else)s, iterate over lists of items (for-each) and also terminate the execution of a pipeline. Using these constructs you have at your disposal a set of tools that empower you to implement pipelines of arbitrary complexity.
Try them out and let us know what you think. Should you need any assistance, as usual just drop us a line at email@example.com or reach us in the in-app chat.
Happy integrating with Cloudpipes!