Error Handling Retry and Child Flows
Complete the full lesson to earn 25 points
Work through each section, then tap “Mark as Complete” on the last one.
Mastering Error Handling, Retry Policies, and Child Flows in Power Automate
Introduction: Why Resilience Matters in Automation
When you begin building workflows in Power Automate, the initial focus is almost always on the "happy path"—the sequence of steps that occurs when everything goes exactly as planned. You connect a trigger, add a few actions, and watch as your data flows from one system to another. However, in the real world, systems are rarely perfect. APIs experience momentary timeouts, users enter invalid data, and network connections drop without warning. If your automation lacks a strategy for handling these inevitable failures, your business processes will stall, leading to data inconsistencies and manual intervention requirements.
Error handling is the practice of designing your workflows to anticipate, catch, and gracefully recover from failures. It is the difference between a fragile script that breaks at the first sign of trouble and a resilient platform that keeps the business running. In this lesson, we will explore the critical mechanics of configuring retry policies, implementing robust error handling logic, and modularizing your architecture using Child Flows. By the end of this guide, you will have the knowledge to build production-grade automations that can self-heal and scale across your organization.
Part 1: Configuring Retry Policies
By default, Power Automate actions are configured to retry a limited number of times if they encounter a transient error. A transient error is a temporary failure, such as a 503 Service Unavailable or a 429 Too Many Requests response from an API. Understanding how to customize these policies is the first step toward building resilient flows.
Understanding the Default Settings
When you add an action to your flow, Power Automate applies a default retry policy. For most actions, this involves a fixed interval of retries. However, not all actions are created equal. Some operations, like writing to a database or sending an email, might require a more aggressive or conservative retry approach depending on the sensitivity of the data and the limitations of the target system.
Customizing the Retry Policy
To modify the retry behavior, you must access the "Settings" menu of a specific action. Within this menu, you will see the "Retry Policy" section. You can choose from four primary types of policies:
- Default: The standard behavior provided by the platform.
- None: The action will not retry upon failure. This is useful for idempotent operations where retrying could cause duplicate records or corrupted data.
- Fixed Interval: The flow waits for a set amount of time between each retry attempt.
- Exponential Interval: The flow increases the wait time between each retry exponentially (e.g., 10 seconds, 20 seconds, 40 seconds, etc.). This is the gold standard for avoiding "hammering" an API that is already struggling.
Callout: Fixed vs. Exponential Intervals A fixed interval is predictable but can be problematic if the target service is suffering from a sustained outage. If you retry every 10 seconds, you might continue to overwhelm a service that needs time to recover. Exponential intervals are significantly more "polite" to external systems, giving them more room to breathe as the outage persists. Use exponential intervals whenever possible for external API calls.
When to Use "None"
While retries are generally beneficial, there are specific scenarios where they are dangerous. If your action performs a "Create" operation on a list without a unique identifier check, a retry might result in the creation of duplicate records. In these cases, you should set the policy to "None" and handle the error logic manually using the "Configure Run After" settings, which we will discuss in the next section.
Part 2: Advanced Error Handling with "Configure Run After"
The "Configure Run After" setting is the engine room of error handling in Power Automate. By default, every action is set to run only if the previous action succeeded. By clicking the three dots on an action card and selecting "Configure Run After," you can change this behavior.
The Four Pillars of Run After
You can configure an action to execute based on the outcome of the preceding step:
- is successful: The default behavior.
- has failed: Use this for logging errors, sending notifications, or performing cleanup tasks when an action fails.
- is skipped: Use this to handle conditional logic where an action was intentionally bypassed, but you still need to perform a follow-up action.
- has timed out: Use this specifically to catch actions that exceeded their allotted execution time.
Implementing a Global Error Handler
Rather than configuring every single action individually, you can use a Scope control to group multiple actions together. By placing a set of actions inside a Scope, you can create a "Catch" block immediately following the scope.
- Create a Scope: Add a Scope action and drag your main process steps inside it.
- Add the Error Handler: Add a new action (like "Send an email" or "Update a log list") immediately after the Scope.
- Configure Run After: Click the three dots on the error handler action and set it to run only if the Scope "has failed" or "has timed out."
- Add a Success Handler (Optional): You can also add a secondary action to run if the Scope "is successful," allowing you to send a confirmation notification.
Tip: The Power of Scopes Scopes are not just for grouping; they are essential for clean error handling. Without a scope, you would have to manually configure the "Run After" settings for every single step in your flow. By wrapping your logic in a scope, you treat the entire block as a single unit, which simplifies your error management significantly.
Part 3: Architecting with Child Flows
As your flows grow in complexity, they become harder to maintain and troubleshoot. A "monolithic" flow that handles authentication, data transformation, business logic, and error reporting is a recipe for disaster. Child Flows allow you to break your automation into smaller, reusable components.
Why Use Child Flows?
Child Flows (or "Flows called from other flows") provide several advantages:
- Reusability: Build a logic block once (e.g., a standard error-logging routine) and call it from dozens of different parent flows.
- Maintainability: If you need to change how an error is logged, you only update the Child Flow, and the change propagates to every parent flow that calls it.
- Security: You can restrict access to specific flows while allowing users to trigger them via a parent flow.
- Readability: Your parent flows become high-level orchestrators rather than cluttered tangles of logic.
Step-by-Step: Creating a Child Flow for Error Handling
Let's create a reusable error-logging flow that sends a notification to a Microsoft Teams channel whenever a parent flow fails.
- Create a New Flow: Select "Instant cloud flow" and use the "PowerApps" or "Manually trigger a flow" trigger.
- Add Input Parameters: In the trigger, add inputs for "FlowName," "ErrorMessage," and "Timestamp."
- Add Logic: Add a "Post message in a chat or channel" action. Use the input parameters to construct a descriptive message.
- Add a Response: Add a "Respond to a PowerApp or flow" action and return a success status code.
- Save and Publish: Give your flow a descriptive name, such as "Utility - Log Error to Teams."
Calling the Child Flow from a Parent Flow
Now that your Child Flow is ready, you can integrate it into your main processes:
- Add Action: In your main flow, search for "Run a child flow."
- Select Flow: Choose the "Utility - Log Error to Teams" flow you just created.
- Map Inputs: The flow will automatically expose the input fields you defined. Pass the
workflow().nameexpression and theresult()of the failed action into these fields.
Note: Licensing Requirements Remember that Child Flows generally require a Premium license for the user running the flow. Ensure your organization's licensing strategy accounts for the use of these components, as they are often treated as independent execution units within the Power Platform environment.
Part 4: Practical Implementation Examples
Scenario: Handling API Timeouts
Imagine you are connecting to an external inventory system that is notoriously slow. You have a "Get Inventory" action.
- Set Retry Policy: Set the policy to "Exponential Interval" with a count of 5 and an interval of 30 seconds.
- Configure Run After: If the action still fails after 5 retries, the flow will proceed to your error handler.
- Logic: Your error handler will call the "Log Error to Teams" child flow, passing the specific error message provided by the inventory system.
- Notification: The team receives a notification containing the exact item ID that failed, allowing for quick manual remediation.
Scenario: Managing Data Integrity
When writing data to SharePoint, you want to ensure you don't create duplicate entries.
- Check for Existence: Before the "Create Item" action, add a "Get Items" action with an OData filter to check if the record exists.
- Conditional Logic: Add a "Condition" control. If the output of "Get Items" is empty, proceed to create the item.
- Error Handling: If the "Create Item" action fails (perhaps due to a validation rule), set the "Run After" of an email notification action to "has failed."
- Clean up: By using this pattern, you avoid redundant records and ensure that every failure triggers a clear, actionable alert.
Part 5: Best Practices and Common Pitfalls
Best Practices for Resilience
- Always include a "Catch" block: Every critical process should have a scope and a corresponding error-handling path.
- Use Descriptive Naming: Name your actions clearly (e.g., "Create Record in CRM" instead of just "Create Record"). This makes reading error logs much easier.
- Centralize Error Logging: Use a single Child Flow for logging errors to ensure consistency across your environment.
- Test Failure Scenarios: Intentionally break your flows during development to ensure your error handling triggers correctly.
- Monitor Execution History: Regularly review the "Run History" in the Power Automate portal to identify patterns of failure.
Common Pitfalls to Avoid
- Ignoring the "Run After" settings: Many developers forget to change the "Run After" configuration, meaning their error handlers never actually execute.
- Over-using Retries: Retrying operations that are not idempotent (like sending an email or charging a credit card) can lead to duplicate transactions.
- Hard-coding values: Avoid hard-coding API endpoints or IDs in your flows. Use environment variables or configuration lists so you can update them without editing the flow.
- Neglecting Timeouts: If you don't configure an explicit timeout, your flow might hang indefinitely, consuming your monthly run quota.
Warning: Infinite Loops If you call a Child Flow from a Parent Flow, and that Child Flow is configured to trigger the Parent Flow, you will create an infinite loop. This will quickly exhaust your API request limits and potentially disable your account. Always ensure your flow architecture is unidirectional.
Part 6: Comparison Table – Retry Strategies
| Strategy | When to Use | Pros | Cons |
|---|---|---|---|
| None | Non-idempotent actions (e.g., payments) | Prevents duplication | No automatic recovery |
| Fixed | Stable systems with short blips | Simple to configure | Can overwhelm the target |
| Exponential | External APIs or unstable services | Reduces load on target | Slightly more complex |
Part 7: FAQ (Frequently Asked Questions)
Q: Can I pass data back from a Child Flow to a Parent Flow? A: Yes. Use the "Respond to a PowerApp or flow" action in the Child Flow. You can define output parameters, which the Parent Flow will then be able to access as dynamic content.
Q: How many levels of Child Flows can I have? A: Power Automate supports nested flows, but keeping it to one or two levels is best for maintenance. Deeply nested flows are difficult to debug and trace.
Q: Does the "Run After" setting apply to the whole flow or just the action? A: It applies to the action you are configuring. If you have a chain of actions, you must configure the "Run After" for each specific step you want to execute during a failure.
Q: What is the maximum number of retries I can configure? A: The limit varies by connector, but generally, you can configure up to 90 retries. However, setting this number too high is rarely beneficial; if a system hasn't recovered after 5-10 attempts, it likely needs manual intervention.
Key Takeaways
- Resilience is intentional: You must design for failure from the beginning by anticipating potential errors and building paths to handle them.
- Retry policies are your first line of defense: Use exponential intervals for external API calls to give target systems space to recover during outages.
- Run After settings provide control: By customizing these, you can turn a simple sequence of steps into a robust, self-managing process.
- Scopes are essential: Grouping your actions into Scopes is the most efficient way to manage error handling without cluttering your logic.
- Child Flows promote modularity: Use them to build reusable components, like standardized logging, which keeps your main flows clean and maintainable.
- Test your failures: Never assume your error handling works; simulate failures to verify that your notifications and recovery actions trigger as expected.
- Avoid duplication: Be cautious with retries on non-idempotent actions, as these can cause data corruption or duplicate business transactions.
By mastering these techniques, you move beyond simple "automation" and into the realm of "systems engineering." Your flows will become more reliable, easier to support, and significantly more valuable to your organization. Start by applying these concepts to one of your existing, "fragile" flows, and you will immediately see the difference in stability and peace of mind.
Continue the course
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles your daily points limit so you progress twice as fast, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× daily points limit
- ✓ Distraction-free lessons