Re: Count errors on "Apply to Each"
Yeah! I use error handling frequently, @ezequiel !
- Create an integer variable before your loops are running (I'd call it errorCountVAR).
- Then after whatever action within the loop fails create two branches one for success, and one for errors.
- In the success branch put the next action that you already had.
- In your error branch put an Increment variable action and increment your variable.
- In your very first failure branch action;
- click the menu dots, and select 'Configure run after',
- now untick 'is successful',
- finally tick 'has failed'.
- Now the next action must bridge the branches, so I usually create a standalone Compose action and name it something pointless (like "Continuance") with nonsense inside.
- Click the menu dots on the Compose, and select 'Configure run after'
- Now make sure that all of the tick boxes are checked and click 'Done'.
- Now do the same again, except this time click on the action below to check its boxes.


Now your flow can continue as normal, and you can use errorCountVAR anywhere after the Apply to each loop.
We can enhance this with array variable and more, but essentially this will count the total number of errors
Advanced - Via Array
If you wanted to check back to which values had errored, I've made an assumption and stored the value name in valueVAR earlier on here:


Now you can call upon this errArrVAR array and have a list of values that failed. In this particular instance the error count is redundant, as you can do a length() function in an expression to count the values that failed.
Even More Advanced
However, you could also have multiple places where errors could be counted within a different loop for a given value. Here you would just:
- Add a Condition action at the end of the loop;
- Yes branch will only run if errorCountVAR is greater than 0.
- No branch is empty
- Move the errArrVAR JSON compose action in to the Yes branch, then in the text of errArrVAR JSON;
- add a comma after the last quote,
- add a new line with "valueErrCount": errorCountVAR (where the errorCountVAR part is the variable)
- Move the Append to errArrVAR after the errArrVAR JSON compose action in the Yes branch.
- Finally, still in that Yes branch, set the errorCountVAR one last time back to zero for the next loop.

Now if you run the flow ... if you call the array in an action after the Apply to each loop, you'll have something like:
[
{
"valueErrored": "value2",
"valueErrCount": 4
},
{
"valueErrored": "value8",
"valueErrCount": 1
},
{
"valueErrored": "value21",
"valueErrCount": 6
}
]
With that you can identify which value had how many errors. I often use this for loops that have 2 or 3 HTTP calls to capture failures in the call. 🙂