How We Can Avoid 8 Nested Levels Of Conditions In MS Flow

There are many limitations with Microsoft Flow. Among these limitations, a few limits which we frequently suffer from are:
  • We can only have 8 nested levels of conditions in a Flow.
  • We can have 250 actions per Flow
  • Apply to Each action will work for 5000 items with Free license.
Here, we will discuss how to avoid the nesting of conditions, with an example.
 

Scenario

  1. On Item create we have to trigger the flow
  2. If the Department is equal to Sales
    1. If Category 1 value of the created item is not blank
        1. Get its Category Manager
        2. If the Manager is blank
          1. If Category 2 is not blank
            1. Get manager
            2. If the Manager is Blank
              1. If Category 3 is not Blank
                1. Get Manager
                2. If the Manager is Blank
                  1. If Category 4 is not blank
                    1. Get Manager
                    2. If the manager is blank
                      1. Send an email to Lead
To understand it better, below is a flow chart which shows nesting.
 


 
Hence, there are more than 8 levels of nesting in our scenario.
 
Note
Here, Category 1, 2, 3 and 4 are Column names, not the value of Category column so we can not use Switch Case here.
 

Analysis

 
If you analyze the Scenario carefully, the main aim of the Flow is to get Manager from any of the 4 Categories and send an email to notify that the item has been created in the Sales Department. If the Manager is blank for all the categories, send an email to the Lead. If we get Manager from any of the categories, we can stop the flow.
 

Solution

 
To break this nesting by reaching to the aim of the flow, including all the conditions, is the one option we have here. To achieve this, we can have the below scenario.
 

Solution Scenario

  1. If Department = Sales
    1. If Category 1 != Blank
      1. Get Manager - > Send an Email -> Stop the Flow
      2. If Manager = Blank
        1. Do Nothing
    2. If Category 2 != Blank
      1. Get Manager - > Send an Email -> Stop the Flow
      2. If Manager = Blank
        1. Do Nothing
    3. If Category 3 != Blank
      1. Get Manager - > Send an Email -> Stop the Flow
      2. If Manager = Blank
        1. Do Nothing
    4. If Category 4 != Blank
      1. Get Manager - > Send an Email -> Stop the Flow
      2. If Manager = Blank
        1. Send an Email to Lead -> Stop the Flow
To understand better, refer to the below flow chart image.
 
 
 

Explanation

 
In this flow, we will check if the value of Category 1 is not blank, we will get the manager. If a manager is blank, we will do nothing, else send an email and stop the flow.
 
If we do not add any action, our Flow will return back to the upper level so in our case it will return back to 1st Level and there we will check for the value of Category 2 and repeat these actions until we get the manager. If we don’t get the manager even from Category 4, we need to send an email to the Lead of the Sales Department.
 
Thus we get manager form Categories checking all the conditions reaching our goal.
 

Summary

 
Hence we analyzed our conditions, broke down the conditions and reached the goal. We can also break down the flow using Nested Flow which means we run child Flow from Parent Flow. There may be other solutions available. We need to analyze our conditions properly to see which solution will be feasible for us to reach the goal.
 
References
 
https://docs.microsoft.com/en-us/flow/limits-and-config 
 
I hope you like this article. Feel free to give your feedback in the Comments Section.


Similar Articles