Flow Control

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

Available flow control blocks are hidden under the plus icon on any empty pipe block in the pipeline editor. Hovering with the mouse over the “+” will expand the flow-control blocks list.

_images/fc1.png

Note: The very first pipe slot in a pipeline will not have these.

Logical Conditions

_images/if.png

Clicking on this icon will insert a logical condition block in your pipeline.

_images/if1.png

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.

_images/if2.png

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.

_images/if3.png

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.

_images/if4.png

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.

_images/if5.png

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).

_images/if6.png

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

_images/loop.png

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.

_images/loop1.png

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 :

_images/loop2.png

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

_images/stop.png

The Stop block terminates pipeline execution once that block is reached.

_images/stop1.png

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.

Conclusion

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 support@cloudpipes.com or reach us in the in-app chat.

Happy integrating with Cloudpipes!