
Hi,
I have an Apply to Each loop that might fail for some values because it tries to find those values in some table that, in some cases, don't exist. Is it possible to get the number of times the Apply to Each fails and add that number into a variable?
Thanks
Ezequiel
Yeah! I use error handling frequently, @ezequiel !
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:
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. 🙂