For some time now we can call Power Automate Flows inside a Business Process Flow Stage. This is perfect for a lot of scenario’s. With this you can automate certain actions. For example we can connect to another system and update inventory. Or we can send e-mail follow-ups to other departments. Or, my favorite, we can start an Approval Flow! In this blog post I’ll share a few of my tricks.
This blog is part of a series about guiding users and teams through their work. This post is about Approval Flows inside Business Process Flows. Click here for an overview of all related post regarding Approvals inside your Business Process Flow. I also added a sample solution you can import in your own development environment so you can see the entire concept in action!
Keeping people in their flow of work by utilizing Asynchronous work or asynchronous processes is one of the key benefits for Business Process Flows. I have written down my thoughts on this subject here. Find out what asynchronous work is, how Business Process Flow can help and more advanced scenario’s.
Create the Approval Flow
Imagine a scenario where we are working an incident reported by one of our customers. They accidentally dropped their new phone which they recently bought from us and now their screen is cracked! In our system we can see that this customer is quite loyal. As the case worker we think they qualify for an immediate replacement of their screen. However it is policy that we ask for approval before we continue to do so. In this case an approval flow inside a Business Process Flow makes perfect sense!
There actually is documentation on this exact subject written by Microsoft. However this is a bit outdated. For example it shows that you need the Parse JSON action to use metadata from the Flow. which is no longer needed as their now is a special trigger available. So let’s go ahead and create our approval flow. Make sure you create the flow inside a solution else the trigger we need will not be available. The Microsoft Dataverse trigger is called: “When a flow step is run from a business process flow”.

What I want to do in my scenario and my flow is of course Ask for an approval. But I also want to track the approval request and the progress inside the Case record. For this I added the following columns to the Case table:
- Approver. A lookup to the User inside our environment we want to ask the approval of.
Tip: Try to automatically (or programmatically) fill in who needs to Approve. For example based on the Case type. - Approval request. A text field where we store the actual request.
- Approval requested by. A lookup to the User who makes the request.
- Approval result. A choice field to store the status of the Approval.
- Approver comment. A text field where we store the comment of the Approver when he accepts or rejects the Approval.

Get the Dataverse UserId from the Flow CallerId
To keep track on who asked for the approval for this case, I want to update the approver column. With the trigger “When a flow step is executed” we get a set of meta data of the Power Automate Flow. One of these is the “UserId”. However this is not the Dataverse UserId. This means we can not use this to fill the look-up directly. The UserId from the metadata is actually the Azure Active Directory Id of the user. Luckily this id is available to us as an column inside the User (systemuser) table inside Dataverse.
We use the Dataverse Action “List rows” and set a filter with “azureactivedirectoryobjectid eq UserId” to accomplish this. Note that I only select the columns systemuserid and fullname. It is good practice to keep the columns to a minimum as this will improve performance.

Now that we know who the user is who initiated the flow we can update the Case record. Thanks to another meta data attribute “BPF Flow Stage Table Row Id” we update the case.

We fill in the Comment send in the Business Process Flow Stage at the Approval Request. We set the column Approval result to “Waiting” and fill the Approval request by Lookup with following code:
first(outputs('Get_userid_from_the_user_who_asks_approval')?['body/value'])?['systemuserid']
Start the Approval process!
Before we start the Approval process we need an email address. Inside the model-driven app on the form the user selects who can approve the request. After the update of the record in the action above we automatically get all the values of the record we update. We use the value of the Approver to get the User using the Dataverse action “Get row by Id”. Again we only select the column we need, in this case the internalemailaddress.

Now we can start the approval by using the action “Start and wait for an approval”. We choose the Approval type “Approve/Reject – First to respond”. We assign the Approval to the User by the e-mail from the action above and in the Details column we add the Comment from the Approval request.

In the Title we add the name of the Business Process Flow for some context. And we add the fullname of the User who asks for Approval with the following expression:
first(outputs('Get_userid_from_the_user_who_asks_approval')?['body/value'])?['fullname']
The result of the Approval Flow so far
Now save the Flow and add it to your Business Process Flow. At the Business Process Flow designer you can add the Flow Step to your stage. You can only select the flows which use the trigger “When a flow step is run from a business process flow”.

Publish and activate the Business Process Flow and see it in action!

I think adding an Approval flow to a BPF works great. It helps to bring someone in to take a look at the case you are working on. However this is not the final result. We of course want to capture the response of the Approval as well. Also we need to look at the “Item Link” functionality of the Approval action. It would be great if we can add a direct link to the Approval flow. As this post is already a bit lengthy, I leave that for my next post!
Hello Ben,
Thanks for sharing your knowledge! When the flow in de BPF has succesfully run, the status of the Flowstep (preview) stays on ‘Processing’. Is this a bug? I would accept that the status of the flowstep will change to Completed.
Looking forwards to hear from you!
Kind regards,
Jelle de Wit (ilionx)
Hi Jelle,
You are right, I think this is a bug. I would also expect this to change to completed. And previously I’ve seen it working this way. I just created another Power Automate Cloud flow without an approval. This also stays on ‘Processing’.
Thanks for your response Ben, good to hear that this was working before. I will wait for a fix!
You need to add a final step in the flow. Dataverse -> Update Record -> Processing Logs -> Use the FlowsWorkflowsLogID field as the ID and update the status as “Succeeded”. The form have to be refreshed by the user to reflect this, but other than that it should work fine.
You are right! This works like a charm! Today I learned 🙂
We could even change it to “Waiting” when we are awaiting the Approval for example.
Hello,
Just curious if there is a way to prevent the case owner to update the approval status directly? Or put another way, how do we ensure it is only the approver that is setting the approval status?
I see that the approval fields are locked in the case form/bpf, but I believe the fields are just disabled. The case owner can still update the field directly via the api.
Thanks,
John
Hi John,
Thank you for your comment. Yes in my example updating of the field is not entirely protected. It is only read only on the current form.
It is possible however to fulfil your requirement. You have to look at he Dataverse Security concepts:
https://learn.microsoft.com/en-us/power-platform/admin/wp-security-cds
Hello Ben,
I am a little bit curious about Data Source used in BPF. Is it possible to use SharePoint list or other Data Sources instead of table in BPF? And Can I customize the UI of the form of BPF when I run the flow?
Thanks,
Daniel
Hi Daniel,
A Business Process Flow is always linked to a table available in Dataverse. You generally would work with a Business Process Flow inside a Model-Driven App. I think it might be possible to add a SharePoint List as a Virtual Entity and then build a Business Process Flow on top of that, but you would still work it inside a Model-Driven App anyways..
There are some options to customize the UI of your Business Process Flow, by changing the components of the field. You can use a XrmToolBox tool called PCF2BPF to change components of fields. I have a blog about this subject here.
Thanks for the information Ben. Can I work BPF inside Canvas App or is it only for Model Driven App?
You’re welcome! From my understanding there are no out of the box components available inside Canvas Apps. You can however build your own as you can see in this blog:
https://powerapps.microsoft.com/en-us/blog/using-business-process-flows-in-a-canvas-app/
Hi Ben,
In our case when user is initiating the approval flow inside BPF 1st time it has been redirected to power automate portal to select country ?
Is it correct behaviour? It is only first time if user is trying to run any flow ? Any way to avoid that to make user experience better?
Something similar to https://community.dynamics.com/365/f/dynamics-365-general-forum/470677/some-users-unable-to-run-flow-power-automate-click-on-run-does-nothing-click-enter-shows-country-selection
Let me know if you know any rectification
Regards,
Rakesh