Using PowerApps & Flow to return Dynamics data immediately

I have worked on Canvas apps previously and think they are AWESOME! I will be creating & mocking up a few Canvas apps over the coming weeks and thought I would blog on the various nifty features or tips that might be useful.

The feature I want to elaborate on with this blog is the 'Respond to PowerApps' function available in Flow.

Previously, if you had a button on a canvas app that called a Flow which created a Dynamics case for example, to view data from that newly created record, it would involve a couple of steps.

  1. Create the case via Flow
  2. Query Dynamics for the latest cases (back in the canvas app) and find details of the newly created cases.

2 calls. Not too much overhead but imagine if you were creating a case, contact, account and multiple other records in that Flow, you would need to query Dynamics for each of those entities to get the latest details, which quickly becomes inefficient.

Using the 'Respond to PowerApps' action in Flow, you only need the one call now.

  1. Create the case via Flow

You can set the values to return from the Flow after its completed. These values can be sourced from the various actions within the Flow so its not necessarily constrained to Dynamics data.

Take for example this scenario below. We have a button that calls a Flow and we will look to update the label with the case ID from the newly created record:


I configured the 'Create Case' button to call a new Flow which is setup as follows:


The first action is the trigger from the PowerApp button. The second action is where I create the new Case record in Dynamics. The third action is where we set the values we want to return back to the PowerApp.

In the example above, I've created a new output field called 'CaseID' and mapped it to the 'Case Number' field from the second step.
You can add varying types of outputs and the options available are visible by clicking on the '+ Add an output' action, which displays the following options:

So you can add multiple outputs which are mapped from multiple sources in the 'Respond to PowerApps' action, all in one Flow!

Back in the canvas app, what I did was setup the button to initiate a variable that will hold the 'Response' back from the Flow action when the Flow is run. This is the action formula for the button:

I'm creating a variable called 'caseRequest', which holds the return values after the Flow 'CreateCaseFlow' has run.

Back to the label, this is the formula I used to update its display text based on the Flow output:

The PowerApp editor automatically detects the outputs you created in the Flow and provides auto-complete capabilities when you are editing the mapping, which is pretty cool:


Once everything is all wired-up, the GIF below shows the final outcome - the label being updated with the Case ID once the case is created:

The above was a very simple example but think of some of the other scenarios this functionality could be useful for e.g.

  • Approval/Decline outcomes
  • Speech to text capabilities
  • Image analysis
  • Customer reference ID's