How to trigger Power Automate flows from Model-Driven Power App Business Process Flows (and get a response!)

I was working on a project the other day and the requirement was for a user of a Model-driven Power App to go through a series of steps to approve an application with a number of data points. I am not the biggest fan of Business Process Flows, (BPFs) but I felt that it did fit this particular use case.

Business Process Flow

One of the improvements of Business Process Flows in recent years is the ability to run an “Action Steps“. You add an Action Step to your stage and trigger either an Action or a classic Dataverse Workflow. In this case, if the organization submitting the application did not yet exist in Dataverse, the users could run a Workflow to create the Account record (and the workflow could update the application record Account lookup).

NAME CHANGES In case you have been living under a rock, the Common Data Service is now known as Dataverse, Entities are Tables, Fields are Columns… this week anyway. Some of the items mention here (like the Common Data Service connector) haven’t yet been updated as of publication.

Action Step

A user can then execute the workflow directly from the Business Process Flow stage by clicking a button.

Running the Workflow

Once the workflow completes, then the users will see a green checkbox meaning the process was successfully executed. Note that my workflow was set to be synchronous, meaning it had to complete before moving forward.

Workflow execution completed!

Running Power Automate flows

You now have the ability to run Power Automate flows from Business Process Flow stages. Fellow MVP Priyesh Wagh posted a great article of this feature last June.

The following is my version of that functionality + the extra step to get feedback from the flow back to the Business Process Flow (which is an important step).

Along with the Action Step is the ability to run Power Automate flows, called a Flow Step (Preview).

Run a Power Automate flow

You will need to create the Power Automate flow before you can assign it to a step.

Create a new flow, but choose the Common Data Service (current environment) When a flow step is executed trigger.

When a flow step is executed trigger

While you have the ability to define some basic inputs, the first question you likely will ask yourself is how to get the record you were working when using the Business Process Flow.

How to you get the record you are working with?

The answer is simply the Common Data Service (current connector) Get Record action. For the Item ID, you can access this from the trigger, and choose the BPF Flow Stage Entity Record Id.

BPF Flow Stage Entity Record Id

From there you would go on to create the rest of the steps of your Power Automate flow.

Power Automate flow

Next you would add the Flow Step in your Business Process Flow to allow users to run the flow from a step in the BPF.

Link Flow to Business Process Flow

The user will now be able to run the flow from the Business Process Flow.

Run Flow from BPF

Are we done yet? Getting a response from Power Automate

The issue I ran into is that since Power Automate flows are asynchronous processes, they will go off and run and no feedback is provided. The Flow action just showed as “Processing”.

So even after the flow completed successfully, the Business Process Flow remained “Processing” which could stall the whole process and if you set the step as required (which it might be) you would be prevented from proceeding forward!

Flow is done… BPF still shows “Processing”

Since the Flow Steps are still “preview” I thought this could be some kind of uncompleted backlog item. However, thanks to reminder from MVP David Yack that we actually had the solution in one of our training labs, I was able to adjust my flow to show the process has completed.

We need to modify the Power Automate flow with an additional Common Data Service (current environment) Update a record action.

The step will need to update the Process Logs record. The Item ID parameter will be the Flows Workflow Log Id value from the originating trigger. And then we can set the status of the BPF step.

Update Process Logs

The Power Automate flow now looks like the following;

Now when we run our Business Process Flow, and trigger the Power Automate Flow to run, after a refresh we now see that the BPF stage has been completed and we can continue on with the next stage or finish our BPF.

Flow shows as completed.

While the ability to add a Flow step is straight forward, the process to update the Business Process Flow from the flow itself is not very intuitive.

Hopefully these steps help you get out of a jam and allow your users to complete the Business Process Flow steps.

Summary

Business Process Flows have evolved quite a bit since they were first introduced in Dynamics CRM 2015 but they still could use a bit of work. The ability to trigger workflows and flows from BPFs adds some next level power to usability of model-driven Power Apps.

Video version of this blog post here: https://www.youtube.com/watch?v=RWanNSmv8FA

Cover Photo by Anthony Rampersad on Unsplash

Nick Doelman is a Microsoft MVP, a Microsoft Certified Trainer (but these days, who isn’t?) and a competitive Powerlifter, hoping to be able to actually compete in 2021! Check out Nick’s online training at 365.Training and follow Nick on twitter @ReadyXRM

12 thoughts on “How to trigger Power Automate flows from Model-Driven Power App Business Process Flows (and get a response!)

  1. Nick, love the article! But for whatever reason I cannot even save this Trigger to use it in the first place. I have tried different environments and different solutions but I keep getting: “Request to XRM API failed with error: ‘Message: An unexpected error occurred. Code: 0x80040216 InnerError: ‘.”

    Any ideas? I have an internal ticket open, but no answer. I am assuming this is somehow related to my Environment config (that i did not setup myself).

    Like

    1. That sucks. I really don’t have an idea of what could be happening. I assume you mean a ticket with Microsoft support? You should have at least received a response (at very least acknowledging your ticket). They can do some background work to see what is happening, and hopefully apply a fix. Sorry I could not be of more help. Cheers, Nick

      Like

      1. Nick, thanks for the reply. Correct, I have a ticket open with MS Support. We will see what they say. Definitely looks like a backend issue since its throwing a HTTP 500 Error.

        Like

      2. Nick, just closing the loop. Finally was able to save. It was definitely an update needed on the backend. I am working in the “Preview” Region so that might be the issue. I now see “Cloud Flow” and “Desktop Flow” when I go to add a Flow to my Solution.

        Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s