In this article, we will learn about flow control actions, different types of flow control actions, and how we can create them in Microsoft Power Automate.
In previous chapters, we learned about some basics of power automate, actions, and variables. Flow Control Actions will let us change our flow from one straight line of actions into multiple branches, conditions, and execution paths.
Types of Flow Control Actions
- Condition Control: Conditions are basically validating a logical statement.
- Switch Control: The switch is a control action designed to find a match for a certain value.
- Apply to Each: It navigates through every single item in an array or list.
- Do Until: It keeps repeating a certain number of actions until the condition is satisfied.
Conditions are basically validating a logical statement. If the statement is satisfied it does some action else, it executes some other action.
If you know some from other programming languages then condition control action is nothing but if-else conditions.
For example, we have a flow in which, when an order is received it checks if the amount is greater than 500 or not. If yes, then it sends an email title,' Large Order Is Received' else, it sends an email 'Small Order Is Received'.
Creating the Condition flow in power automate
- Let's create a condition flow in power automate for that assume that the order is entered manually. Most of the time this is not the case. Order is received either using the API call or power apps or by another system.
- Here, we create a manually triggered flow. Which has two text inputs one for Order Item and the other for Category. Also, one numeric input for Amount. Click on the New step.
- Initialize the variable Order Size of type String. Go to the New step.
- Select Condition (Control) from actions.
- To add condition select Amount from dynamic contents. Select the "is greater than" condition and enter the value 500.
- Add the action for both If yes and If no by selecting Set Variable action.
- Select the variable Order Size and enter the value for both. If our condition is satisfied then the Order Size is Large else, it is Small.
- In the New step, we are sending an email notification of our order. Select Send an email notification (V3) from actions.
- Add the recipient's email address. Give a subject to the email you can also, concatenate the variable in the subject. Add body for email by adding dynamic content for Order Item, Amount, and Category. Click Save.
- Save and Test the flow. Here, we are putting the Amount as 200 which is less than 500, which comes under the Small size of orders. Click on Run flow.
- We have received an email titled "A Small order is received" for the amount 200.
- Similarly, we can receive an email for an amount greater than 500 titled "A Large order is received"
This was all about Condition flow action in Microsoft Power Automate.