error-handlingoffice-addinspower-automateskip

Power Automate- Alert when an action in the flow gets skipped


Context: this flow called "Email to Case Responsibles" aim to send an email notification. However sometimes it does not find the user, and actions get skipped, and the flow result is "Sucessfull" making it impossible to detect errors. I added an action that goes after the "Applyto each" that only runs if it was skipped, to post a message in teams letting me know the flow actually FAILED (previous action returned no output and thus skips subsequent steps. However I am encountering a bug on the action triggered when previous step is skipped since it also skips this action! start of flow from form

screen of flow

The action in the red box should run (since the apply to each was skipped) and instead it is getting skipped too. enter image description here

I tried with Condition leg(outputs('Buscar Analista') less than 1 This is not a solution because when applying a formula to the output, when you have null output, it gets skipped too. Also it fails in a most annoying way since it creates another Apply to each loop.

I also tried Compose variable to make it plain text before getting to the conditions and did not work either.

Also tried the "Filter Array" action and the "Select" action but both failed for the same reason above.


Solution

  • I added an action that goes after the "Applyto each" that only runs if it was skipped, to post a message in teams letting me know the flow actually FAILED

    Based on your screenshot the action "aplicar a cada uno" (your foreach loop) is marked with a green checkbox, indicating it has executed, however no records are found to run the inner loop. This explains why your "run after - skipped" doesn't work.

    The solution is to verify the absense if items with a conditions:

    1. Add a condition shape to count the elements/verify it's not null. Use the length() expression to count items in an arry or check for null values - depending on your condition.
    2. In case valid records are returned start the for-each loop.
    3. In case no (valid) records are returned execute the 'Post message in a chat or channel'

    Below is a simple example with dataverse, note that the "List rows" did not return any values. You see we execute here the "NoRecordsFoundAction"

    Power Automate check for null items in an array