Let us take a simple example of creating lead to understand how we can call Flow from PowerApps.
Log in to PowerApps Studio and create the form as below.
- TextInput for entering the Last Name, First Name and Email ID.
- Button to call Flow.
- The label named GUID which will display the GUID of the created lead record.
Now select the button, go to Action menu and click on Flows to create a new flow.
Click on create a new flow.
Select Instant – from blank option
Select PowerApps as the trigger.
Add a new Step – Create a new Record (Dynamics 365)
To create a new record step, specify the Dynamics 365 Organization Name, select Leads as the entity name.
For the Last Name field, click Ask in PowerApps that will generate the parameter to which we will pass the value from our PowerApps.
The generated parameter.
Repeat the above step for the First Name and Email field.
*for Topic field we have passed a hardcoded value.
Save the create step and add a new step “Respond to a PowerApp or flow”
Here we have selected output of type Text
We have added the output parameter as varLeadId and selected leadid as the unique identifier.
Save the Flow and navigate back to PowerApp and select the flow created for our button.
After adding the Flow, the next step is to update the formula to send the field’s value to the flow and also to receive the output from it.
Below will be our formula to pass the text to the flow.
But as we are expecting the GUID in return, we need to update it.
We are using the Set function to set the variable varResponseFromFlow with varleadid output.
Also, we have updated the label field for GUID with the variable
Now let us save the changes and run the PowerApp.
On clicking the button, we can see the GUID updated on the label on the form.
Back in our Dynamics 365 CE, we can see the lead created.
Thus we saw how easy it is to write a PowerApp which interacts with Dynamic 365 CE using Flow. We took a very basic example to understand how things glue, but we can clearly see the potential here to implement complex real-world scenarios with ease.
Hope it helps..