Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 38 ยท Governance and Patterns

Flow Patterns That Scale: Child Flows, Pagination, Idempotency

Reusable designs for solid flows: child flows, trigger conditions, trigger concurrency, pagination and server-side filtering, idempotent processing, batching, configuration and logging.

When you build a few flows, almost any layout works. When you build fifty, maintain them for years, and let them process thousands of items, the same few designs keep appearing. Using them early saves you from duplicate emails, half-processed batches and flows nobody dares to change. This lesson collects the patterns that pay off most: child flows for reuse, trigger conditions and concurrency for control, pagination and server-side filtering for large data, idempotent processing for safe repeats, and configuration and logging for operations.

The designer is not available on this site, so the settings are described in words and the runnable examples are stand-ins that model the logic.

Pattern 1: child flows for reuse

If the same steps appear in several flows ("create a ticket and notify the team", "log an audit record"), build them once as a child flow and call it from the parents.

How it works:

  1. Create the child flow inside a solution, with the trigger Manually trigger a flow, and define its inputs (text, number, file...).
  2. End the child flow with the action Respond to a PowerApp or flow, where you define the outputs.
  3. In the parent flow, add Run a Child Flow (Flows group), select the child and fill its inputs. The outputs appear as dynamic content.
  4. The parent and the child must be in the same solution, or at least in the same environment with the right sharing.

Benefits: one place to fix a bug, smaller parents, and an easy way to break up a flow that is too large, since each child run has its own action budget and its own run history. Cost: an extra run per call and a bit more setup, and the child's run-only connection settings must be right (child flows use the connections you set when adding the child; verify them after import).

flowchart LR
    P1["Parent flow A"] --> C["Child flow<br/>Create ticket and notify"]
    P2["Parent flow B"] --> C
    P3["Parent flow C"] --> C
    C --> O["Outputs: ticket id"]

One implementation, three callers.

Pattern 2: trigger conditions and concurrency

A trigger like "When an item is created or modified" fires for every change. Most of those runs would do nothing. A trigger condition (Settings of the trigger) is an expression that must be true or the run is not even created, saving runs and noise:

TEXT
@equals(triggerOutputs()?['body/Status/Value'], 'Ready')
@and(not(empty(triggerBody()?['Approver'])), greater(triggerBody()?['Amount'], 100))

Also in the trigger's Settings is Concurrency control. Turn it on and set degree of parallelism to 1 to process events strictly one at a time. This prevents two runs updating the same record or counter at once, at the price of throughput. Higher values allow parallel runs for independent events.

A related trap: a flow that updates the same item it triggers on can trigger itself in a loop. Prevent it with a trigger condition (only act when a field has a particular value and then change that field), or use a dedicated "processed" column and filter on it.

Pattern 3: big lists, pagination and server-side filtering

Connectors return data in pages. "Get items" with default settings returns 100 items; with Pagination switched on in its Settings (and a Threshold such as 5000) it returns more, up to a plan-dependent limit. Rules of thumb:

  • Filter on the server first. Use Filter Query (OData syntax, such as Status eq 'Open' and Amount gt 500) and Top Count, so you fetch only what you need. This is faster and avoids hitting limits.
  • Use Order By for a deterministic order, and Select columns where available.
  • For very large sets, process in batches (take 500, handle, continue from where you stopped), and keep a "last processed id" or a "processed" flag in the data source.
  • A delta approach: remember the last run time and query "modified since" instead of reading everything again.
JS Stand-in: paging through a large list

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Pattern 4: idempotent processing

Flows get triggered twice, retried after timeouts and re-run by humans. Make the work safe to repeat:

  • Check first. Before creating a record, query for it by a unique business key ("invoice number"). Create only when none exists, or update when it does (upsert).
  • Mark as done. Keep a Processed flag or a ProcessedOn date. Filter the trigger or query on Processed eq false, and set the flag as the last step.
  • Use natural keys, not run ids, so two runs for the same business event recognize each other.
  • Do the irreversible step last, after all checks, so a failure earlier leaves nothing to undo.
JS Stand-in: processing the same event twice

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Pattern 5: configuration, not constants

Do not scatter magic values. Put thresholds, mailbox addresses, site URLs and list names into environment variables (environments and solutions) or a small configuration list that the flow reads at the start. Changing a limit becomes an edit to a value, not a change to the logic.

Pattern 6: logging and correlation

For anything important, write a small log row at the start and end of the run: run id, business key, start, end, result. Use workflow()?['run']?['name'] for the run id. When a user says "invoice 204 never arrived", you search the log by invoice number, find the run and open its history. Include the run link in alerts (monitoring).

Pattern 7: small, named steps

  • Rename every action; use Compose actions to show intermediate values in run history.
  • Keep scopes short: Prepare, Process, Notify.
  • Prefer one flow per business process; split when it exceeds what you can explain on one page.
  • Comment on non-obvious expressions (the action description field).

Pattern 8: scheduled batch with an idempotent core

For a nightly job: Recurrence trigger, query for items needing work (filter on Processed eq false, top 500), loop with limited concurrency, mark each as processed, write a summary row, and alert only on failures. If the job is interrupted, tomorrow's run continues with the leftovers.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a child flow mainly used for?

    A child flow is a reusable flow called from parents with inputs and outputs.
  2. 2. Where do you put an expression that decides whether a trigger should even start a run?

    A trigger condition prevents unnecessary runs from being created.
  3. 3. Why filter on the server with a Filter Query instead of filtering in the flow?

    Server-side filters reduce the amount of data transferred.
  4. 4. What makes processing idempotent?

    Safe repeats come from existence checks and done markers.

Summary

  • Use child flows for reuse and to split large flows; call them with Run a Child Flow.
  • Add trigger conditions to avoid pointless runs and set trigger concurrency to 1 when order or exclusivity matters; guard against self-triggering.
  • Filter on the server, paginate, process in batches and use delta queries.
  • Make processing idempotent with existence checks, Processed flags and the irreversible step last.
  • Keep settings in environment variables, log every important run, and keep flows small and named.

Next: Limits, Licensing and Performance