If you send out an Approval from within a model-driven App, you probably want to see the Approval Result in Dataverse. In this post we continue where we left off in our Approval from inside a Business Process Flow. Let me give you some background on the various Approval Flows and how they work. Including a tip on how to keep your Cloud Flows clean.
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.
Expanding the Case BPF
We are currently still working the Case of a broken screen. We are dealing with a loyal customer, so we asked Approval of our manager to immediately replace the screen. He either gives Approval to do so, or he does not. We want to capture his answer within our system so we can continue working the Case.

We prepared our data model already for this as seen in my first post about Approvals. I want to fill in the fields Approval result with the result of the Approval. And as our manager might type a comment in his response, I want to capture this in the Approver comment field.

Types of approval
There are several types of Approvals you can send. The “Approve / Reject” options will send out the standard Approval with only these 2 options. If you go for the “Custom Responses” you can choose your own set of options which an Approver can choose from. Depending on the second part of the available options the cloud flow continues on a different time. If you select in the category “Everyone must approve / Wait for all responses” the cloud flow will continue after everyone in the “Assigned to” list has responded. If you select “First to respond / Wait for one response” the flow will continue immediately after 1 response.

In our scenario we use the “Approve / Reject – First to respond” option. Remember to tweak your capture based on your own requirements. So after our manager responds to the Approval the cloud flow continues and we get the feedback from the manager. We want to save that feedback to the Case record we are working on. We add a condition based on the response as you can see in the overview below.

The condition however requires some expression to make your flow cleaner. As the Approval mechanism can contain multiple responses we will take the first of those responses. This will make sure we do not get an unwanted ‘For each’ inside our Cloud Flow. That helps a lot in readability of our Flow.
first(outputs('Start_and_wait_for_an_approval')?['body/responses'])?['approverResponse']
Now let’s get our Approval result in Dataverse
Inside the two branches of the condition we choose the “Update record” action in Dataverse. Select the Table Cases and the Row ID is the ID we get from the parameters of our trigger “When a flow step is executed”, the “BPF Flow Stage Id”. We set the “Approval step done?” to “Yes” and the “Approval result” to “Approved”. Of course if we are in the other branch we set the “Approval result” to “Rejected”.

In the field “Approver comment” we can add the comment our manager added “Responses Comment”. Again we need to specify that we want the first of the Approval responses to avoid a “For each”. Sadly if we do that we can no longer select the “Responses comment” from the Dynamic Content menu to help with our expression. We must type out the following code:
first(outputs('Start_and_wait_for_an_approval')?['body/responses'])?['comments']
Tip: What I like to do is create a dummy “Compose” action. In this action I can select the attribute I want and use the “Peek Code” option to find out what the technical name is. This name I can then use in the expression I am actually working on.
That’s it, we are done! We have now saved the result and comment of the Approval to our record. See the gif below to see this in action.

If you think I am done with explaining my tips for Approvals inside a BPF now, you are mistaken! Yes we have created an Approval, added the record link to it and now captured the result, but I want to do one more thing! Automatically update the Business Process Flow Stage depending on the outcome of the Approval. But that is for a next post.
I can’t seem to figure out how to get information on who responded to the approval. In my case i have a group of people and the first one to respond i would like to log who that is.
But it dosn’t look like that information is in any of the dataverse approval tables?
I do not know much about internal storage of the Approval data inside Dataverse. That is interesting to dig into sometime.
However, I think you can get information about “The First to Respond” inside the Cloud Flow. From there you can log the Approver in a field of your choice.