Power Automate and the Power Apps trigger – part 2 – Passing parameters

This blog series will cover the Power Apps trigger in Power Automate. I will describe how you can trigger a flow from your Power App, how you can provide parameters from your Power App to your flow and how to impersonate actions.

This is part 2 of this blog series, which will cover passing parameters from your Power App to your flow.
Part 1 will cover triggering a flow from your Power App.
Part 3 will cover impersonation of your flow

Passing parameters from your Power App to your flow

In part 1, I explained how to trigger a flow from your Power App. But what if you want to pass information from your Power App to your flow?

You can use parameters for this.

Ask for input and provide input

Like mentioned in the part 1, there are two triggers: PowerApps and PowerApps (V2). Both have different ways to ask the Power App for input. I will cover both here.

PowerApps trigger

With the PowerApps trigger, you can ask for input at any place within your flow using Ask in Power Apps from your Dynamic Content:

In the example above, I’ve added the Dynamic Content attribute to a Compose action, but you can use it in any type of action that needs input (e.g. Update item or Send an email). The reason why I put this into a Compose action is that Power Apps will use the name of the flow action as parameter name in your Power App. If I save this flow and add the flow to my button as I explained in part 1, you can see that a required parameter has been added to my PowerFX formula:

As you can see, the parameter is now called Compose_Inputs, which isn’t very declarative. That’s why I always rename the Compose action in my flow to describe what that parameter is used for:

The problem with the PowerApps trigger is that it will always keep asking for parameters that have been declared in the past, even if they’ve been removed already. And since the parameters are always required, you have to provide a value in your Power App when calling the flow:

The only way to make this Compose_Inputs parameter disappear is to completely remove and recreate your flow from scratch. That’s why it’s so important to determine which parameters you need before you start building your flow. If you don’t want to completely recreate your flow, you can just enter an empty value for the non-existing parameter. Make sure to provide some comments as well!

PowerApps (V2) trigger

When using the PowerApps (V2) trigger, you can only ask for input from within the trigger itself (just like the For a selected item or the Manually trigger a flow trigger):

The advantage of this is that you don’t have your input scattered over multiple actions within your flow. Naming your parameters is also a lot easier this way. However, when referencing this flow in your Power App, it will not directly show the parameter name:

As you can see, the parameter name is ‘text‘ instead of First name. It does however provide the First name as description to the text parameter. So it’s a bit unclear, but still workable.

The PowerApps (V2) doesn’t have the problem of asking for old parameters. If you’ve deleted a parameter, it will not be asked again after you’ve refreshed the flow in your Power App.

Passing parameters from your flow back to your Power App

Passing parameters back to your Power App is also possible. You can use the Respond to a PowerApp or flow action (from the PowerApps connector) for this:

This action will give you the same options as the Add an input from the PowerApps (V2) trigger, which allows you to pass various data types back to your Power App. You provide a name for the parameter and its value:

When you go back to your Power App and refresh your PowerFX formula, you will now see that the Run() command can be extended with the parameter you’ve just configured:

Showing the output

Running this command doesn’t get the response into your Power App yet, because there is no place to present it if you’re running it just from a button. To make sure you get the output you want, you need to put in into a variable of choice.

If you’re using a single screen Power App or don’t need the output to be used on another screen, you can use the UpdateContext() function for this:

UpdateContext({varResponse: 'Testing-PowerAppsbutton'.Run("Rik").response})

If you want to use the output on other screens as well, you can use the Set() function for this:

Set(
    varResponse,
    'Testing-PowerAppsbutton'.Run("Rik").response
)

After this, you can use this variable within your Power App to show the output (e.g. in a Label control):

Please note that the connection between a Power App and a flow will time out after 2 minutes. So if you’re having a complex flow that will run for more than 2 minutes, you won’t be getting any response back!

Stay tuned for the next part of this blog series in which I will cover impersonation.

One Reply to “Power Automate and the Power Apps trigger – part 2 – Passing parameters”

  1. First and foremost, I must express my gratitude to the author for delving deeper into the realm of Power Automate and Power Apps triggers in this captivating Part 2 of their blog series. As someone who has been exploring the vast capabilities of these tools, I am always eager to learn more and uncover new ways to streamline workflows and enhance productivity. This article certainly did not disappoint!

    0
    0

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.