Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 38 ยท Connectors and Integration

Calling Power Automate Flows from Apps

Learn how a canvas app triggers Power Automate flows: the Power Apps trigger, passing inputs, returning outputs with Respond to a Power App, errors and when to use a flow.

A canvas app runs in the user's browser or phone and can only do what its formulas and connectors allow. For work that is long, needs elevated permissions, or touches many systems, you hand the job to Power Automate. A flow runs in the cloud, and the app starts it with a button press and (optionally) waits for an answer.

When to use a flow

Use a flow when you need to:

  • Run steps that take more than a few seconds or must continue after the app is closed.
  • Send approvals (the Approvals connector) and wait for decisions.
  • Perform several actions in order with retries and branching.
  • Use credentials that the user should not have (a service account).
  • Reuse the same process from several apps or from a schedule.

Do it directly in the app when the action is one quick call (Patch to a table, a single email). Keep the app responsive and the logic easy to read.

Creating a flow for an app

In a canvas app, open the Power Automate pane in the left rail and choose Add flow, then Create new flow (or Create from blank). The designer opens with a Power Apps (V2) trigger. In the trigger, Add an input and pick the type: Text, Yes/No, Number, File or Date. Each input is a parameter your formula will pass.

Then add actions, for example Send an email (V2) using the trigger's inputs as dynamic content. To return values, finish with the Respond to a Power App or flow action and add outputs (Text, Number, Yes/No...). Save the flow, give it a clear name, and it appears in the pane so you can attach it to a button.

Running the flow from a formula

Select the button, set its OnSelect, and call the flow like a function:

TEXT
Set(
    varResult,
    NotifyManager.Run(txtRequestId.Text, Value(txtAmount.Text))
);
If(
    varResult.approved,
    Notify("Manager approved", NotificationType.Success),
    Notify("Manager declined", NotificationType.Warning)
)

NotifyManager is the flow's name without spaces; .Run(...) takes the inputs in the order they were defined. The result is a record whose fields are the flow's outputs (here approved). If the flow has no response action, .Run returns without waiting for a result.

App to flow round trip

Button OnSelect calls Flow.Run
Flow Steps run in the cloud
Response Outputs return to the app

Inputs go in, outputs come back.

1 / 2

Timing and limits

  • A synchronous call from the app waits for the response. The app expects an answer within about two minutes (the response action has its own time limit); for longer processes, return early with an ID and let the flow finish in the background.
  • Flows started from an app run as the user (for connections like SharePoint, if the flow's connections are configured to use the invoker) or as the flow owner, depending on the connection settings (Run only users under the flow's details). Check this: it decides whose permissions apply.
  • Flows are subject to licence and request limits.

A stand-in for the round trip

The flow service cannot be reached here, so this stand-in imitates the pattern: an async function takes inputs and returns an output record, with a timeout and a failure path.

JS Stand-in: app calls a flow and waits

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

No output.

Returning errors from a flow

In the flow, add a Condition and use a second Respond to a Power App or flow action for the failure case, returning an output such as ok = false and message = .... Another way is to let the flow fail: the app then gets an error you can catch with IfError. A clean pattern is to always return a status from the flow, so the app can show a friendly message without guessing:

TEXT
With(
    { r: SubmitRequest.Run(txtTitle.Text) },
    If(r.ok, Navigate(scrDone), Notify(r.message, NotificationType.Error))
)

Passing a collection of rows

A flow input cannot be a table directly. Convert the table to JSON text and pass it:

TEXT
SaveLines.Run(JSON(colLines, JSONFormat.Compact))

In the flow, use Parse JSON with a sample schema, then Apply to each. JSON text keeps the contract explicit and avoids one-input-per-column.

JS Stand-in: pass a collection as JSON text

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

No output.

Good practices

  • Name flows after the verb and object (SubmitExpenseClaim), not Flow1.
  • Keep apps and flows in the same solution (Solutions and Environments).
  • Test the flow's run history in Power Automate when the app behaves oddly: each run shows inputs and outputs.
  • Never trust app inputs blindly: validate them again in the flow.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which trigger starts a flow from a canvas app?

    The Power Apps (V2) trigger lets an app call the flow and pass inputs.
  2. 2. How does a flow send values back to the app?

    That action defines outputs the app receives as a record.
  3. 3. How should an app pass a table of rows to a flow?

    Use JSON() in the app and Parse JSON in the flow.
  4. 4. A process that takes ten minutes should...

    Synchronous waits are limited, so return early and let the flow continue.

Summary

  • Flows handle long, privileged or multi-system work; formulas handle quick local actions.
  • Add a flow with the Power Apps (V2) trigger, call it with FlowName.Run(...), and return outputs with Respond to a Power App.
  • Pass collections as JSON, always return a status, and keep apps and flows in one solution.
  • Know whose permissions the flow's connections use.

Next: SharePoint, Outlook and Teams Integration