Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / ReadyXRM / How to trigger Power Automa...

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

Nick.Doelman Profile Picture Nick.Doelman 1,947 Most Valuable Professional

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 form 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 though 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.

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

Comments

*This post is locked for comments