Changing the behavior of Until Loop when the loop limit is reached
Published Dec 14 2020 11:53 PM 2,363 Views

 

The default behavior of the Until Loop is to Succeed if all actions inside it are successful, and depending on your run after behavior, when the Loop limit is reached. This behavior can be changed from the code view of the Logic App.

 

The default behavior:

 

Actions are Successful, the Loop hits the limit and returns Success as all actions were successful. The limit was hit but the result is Success for the Loop.

 

Add loops to repeat actions - Azure Logic Apps | Microsoft Docs

 

Omar_Abu_Arisheh_1-1607967523942.png

 

 

Let's say you wish to change this behavior and you require the Until Loop to fail when it reaches the Loop Limit.

 

Fail Loop when limit is reached behavior:

 

To let the Until Loop fail when the limit is reached; just add the below in the code behind in the JSON of the Until Loop, this option is not available in the GUI yet (at the time of writing this blog):

 

"operationOptions": "FailWhenLimitsReached",

 

clip_image002.png

 

 "Until_2": {

                "actions": {

                    "Execute_stored_procedure": {

                        ………………………..

                    }

                },

                "expression": "@equals(variables('myUntilStop'), true)",

                "limit": {

                    "count": 5,

                    "timeout": "PT1H"

                },

                "operationOptions": "FailWhenLimitsReached",

                "runAfter": {

                    "Initialize_variable_8": [

                        "Succeeded"

                    ]

                },

                "type": "Until"

            }

 

 

and this is how to do it! As easy as that.

Version history
Last update:
‎Dec 14 2020 11:53 PM
Updated by: