In this article we are going to analyze the behavior of the “FOREACH” block.
The “FOREACH” block is a block that allows you to iterate on collections of entities in Deepser and perform one or more actions for each entity in the collection.
The block “FOREACH”, is located in the menu: Logic, to access it will be necessary to click on the search bar that will appear:
The “FOREACH” block visually will have 2 branches: the left branch that is to be considered the continuation of the execution of the flow, and the right branch in which you will have to place the actions to be performed for each iteration of the cycle
Note: If you insert an end flow block in the left branch you will get the result of ending the execution of the flow.
Example of configuration of the “FOREACH” block
Suppose we want to send an email notification to the user who created a password in the password manager when it is expired, for this example we will consider expired a password whose Expired field (field managed by a system automatism) is set to yes.
To do this we must initially recover the collection of entities of type “DeepPassword – Password” expired, to do so we will have to go to insert a block “Lookup Records” configured in this way:
At this point we can iterate on the password entities by adding below the previous block a “FOREACH” block, in whose right branch we are going to insert a “Send Email” block:
The “FOREACH” block will be configured as follows:
While the “Send Email” block will be configured as follows :