How to break "Apply to each" loop in power automate using variables | TrendingTechnology

Hello Everyone,

In this example, I have explained how to close the "Apply To Each" loop in Power Automate using variables.

I'm working on one of the Approval Flows, and I want to close my "Apply To Each" loop. However, I can't terminate it by using a direct action in Power Automate, i.e., "Terminate" (as we can't use that action within the "Apply To Each" loop). Therefore, I'm closing my loop using variables.

To use this method for closing the loop, I have employed 5 steps in my Power Automate Flow.

Here is my Power Automate Approval Flow:


Power Automate Flow


Step 1: Initialize a variable before the "Apply To Each" loop with the TYPE set as "Boolean" and the value set to "TRUE."

Step 2: In this step, check if the value of the previously initialized variable (the variable declared in STEP 1) is set to "TRUE."

Step 3: If you have additional conditions within the loop, and if those conditions are TRUE, apply the loop. In this step, use the "SET Variable" Action to set the value of the variable declared in Step 1 to "TRUE."

STEP 4: If you wish to close the loop, use the "SET Variable" action again. In this step, use the "SET Variable" Action to set the value of the variable declared in Step 1 as "FALSE."


STEP 5: Utilize the "SET Variable" action to set the value of the variable declared in Step 1 to "FALSE."


I hope you found this tutorial on closing "Apply To Each" loops in Power Automate helpful! Feel free to share your thoughts or ask questions in the comments below. Your feedback is valuable and can help improve future content. If you have any specific topics you'd like me to cover in future blogs, let me know!

Comments

Post a Comment