其他分享
首页 > 其他分享> > How To Trigger A Power Automate Flow From PowerApps

How To Trigger A Power Automate Flow From PowerApps

作者:互联网

Introduction

While working with PowerApps, many times we come across a situation where we need to perform some operations through Power Automate. In this article, we will learn all about calling a Power Automate flow, passing parameters to the flow, and returning the data to the PowerApps. We will see below three scenarios:

  1. How to call a Power Automate flow from PowerApps
  2. How to pass the parameters to Power Automate from PowerApps
  3. How to respond to PowerApps from Power Automate flow

Let us see all these scenarios one by one,

1. How to trigger a Power Automate flow from PowerApps

Overview

  1. Create a canvas app and add a button
  2. Create an instant flow that has the trigger as PowerApps button. This flow will send an email to a fixed person. 
  3. Call this instant flow from the button

Implementation

  1. Create an instant flow


     
  2. Give some name to the flow and choose PowerApps as a trigger as shown below:

     
  3. Add the steps required as per your business logic. In this case, I have added an action which is sending an email to one of the users.


     
  4. Save the flow
  5. Create a canvas app and add a button or icon on the screen
  6. Select the button and navigate to the Action tab and you will find the option to add a Power Automate
  7. From the list of available instant flows, click on the recently created flow, i.e. "Send Email"


     
  8. Once the flow gets added, just close the brackets and we are good to go.
  9. Now when you click on a button, a flow will be triggered and it will send an email to the specified user as shown below:

2. How to pass the parameters to Power Automate from PowerApps

Overview

  1. Create a canvas app, add a button, and two text boxes.
  2. Create an instant flow that has the trigger as PowerApps button. This flow will send an email to the user's emails specified in the text boxes.
  3. Call this instant flow from the button

Implementation

  1. Create an instant flow


     
  2. Give some name to the flow and choose PowerApps as a trigger as shown below:


     
  3. Now we want two parameters from PowerApps text boxes, so we will initialize two string variables.
  4. Initialize the first variable with the name varEmail1 and choose the type as a string. Also, rename the action name to "email1". Renaming the action name will create a parameter with that name.



    Once you click on "Ask in PowerApps", it will create a parameter with that name. See the below screenshot:


     
  5. Similarly, initialize the second variable with the name varEmail2 and choose the type as a string. Also, rename the action name to "email2".



    Once you click on "Ask in PowerApps", it will create a parameter with that name. See the below screenshot:


     
  6. Save the flow.
  7. Create a canvas app and add two text boxes and a button on the screen
  8. Select the button and navigate to the Action tab and you will find the option to add a Power Automate
  9. From the list of available instant flows, click on the recently created flow, i.e. "Send Email using Parameters"


     
  10. Once the flow is added, it will ask you to pass the parameters that we created in the power automate.


     
  11. In this case, we will pass the two email addresses from two text boxes as shown below:
    SendEmailusingParameters.Run(TextInput1.Text,TextInput2.Text)
  12. Now when you click on the button, these parameters will be passed to the Power Automate and flow will send email to those email addresses. 

3. How to respond to PowerApps from Power Automate flow

Overview

  1. Create a canvas app, add a button, and two text boxes. We need to multiply the values from these two text boxes using flow.
  2. Create an instant flow that has the trigger as PowerApps button. This flow will calculate the multiplication of these two values and respond to the answer to the PowerApps label.
  3. Call this instant flow from the button

Implementation

  1. As explained in an earlier section, create an instant flow (I have used flow name as "Flow to Respond PowerApp"s) and initialize two Integer variables (varNum1, varNum2). These variables will take values from PowerApps.


     
  2. Add an action called Respond to PowerApps, Use Type of Output as Number


     
  3. Give some name to the output parameter (Say "MyAnswer"). Multiple the two variables as shown below:

    int(mul(variables('varNum1'),variables('varNum2')))


     
  4. Save the flow
  5. Now, as explained in the earlier section, on the button add the recently created flow and pass the values of two text boxes as shown below. This time instead of calling a flow directly, we will use one variable to save the response of a flow. Here I have used a variable named varFlowOutput to save the multiplication of the numbers:


     
  6. Add one label, which will show the output of the flow. Set the text property of the label to varFlowOutput.myAnswer. myAnswer is the output parameter name that we have created in step 3.


     
  7. Now run the flow by passing the numbers. You can see below that the flow ran successfully and the label is showing the answer:

In this way we have learned below topics:

  1. How to call a Power Automate flow from PowerApps
  2. How to pass the parameters to Power Automate from PowerApps
  3. How to respond to PowerApps from Power Automate flow

Note
When you edit the flow in future, sometimes your flow may not get triggered. In that case, you need to delete the button and add it again and then attach the flow.

 

标签:PowerApps,Power,Flow,button,flow,will,Automate
来源: https://www.cnblogs.com/lingdanglfw/p/15870821.html