MS Power Automate : Act on Approvals directly from Dynamics CRM on column value change/Button click

What is Issue?

There are lots of business scenarios where the approval requires on the records before proceeding or pushing it to next levels or complete the process. For these scenarios now we have the Power Automate Approvals. When approvals are triggered, it goes to the approvers mailbox to approve it, then approver can happily act on it without navigating to the other systems. But in some cases, Approver gets lots of the approval requests and he need to check each request by navigating to the system. After checking the approval again he need to switch the screen and approve it from mailbox. Now the frustrated approver says, “I can see all my requested records in system directly, I don’t want to go back to the mailbox again!!” and he/she will ask you “is it possible to approve the request from the system only?”

The Reason-

It is easier to act on approval from email which is very quick and easy process. But how the approval action works in power automate is something not explored. So I can say less exposure to the Approval tables in Dataverse.

Solution-

Power Automate provides Approval actions. Once you add it on your flow, system automatically installs some solutions containing approval tables and components in your selected environment(instance).

First lets have look at these tables-

  1. Approval – contains the Approval details
  2. Approval Request – contains the information of who requested and who is approver
  3. Approval response – contains the information about approval responses
  4. Flow Approval – contains the Approval action details which is used in actual power automate flow

In the case where you have to mark the approvals complete and resume the approval flow, you have to look for Approval table and Flow Approval table.

Lets see an example of flow-

I am using column on Account form to act (approve/reject) the approval for the account without using my mailbox to approve the request.

On change of Approval Status column value my approval action should be tracked and flow should be proceed as per my response. On completion of the request I should receive the mail saying approval succeeded or approval rejected.

This is how my approval flow looks like- I am manually triggering the approval for the demo purpose.

When I ran this create Approval Flow I received below approval request on my mailbox with the account URL in link in it.

Let’s see the another flow which will trigger when I update Approval Status column value.

Next step will be finding the correct approval record based on Account ID. So as I mentioned I have added the Item Link to the approval with record id, so I can query the approval where Item Link contains the account id for which flow is triggered. Just for the information you can see the Approval table column which I am using for this purpose-

So next step on my flow is to list the rows from Approval table where linked item contains account id and pending for approval-

Once I got the response then I can find the Flow approvals associated with the Approval record and from this Flow Approval row “Flow Notification URI” column value is the useful URL for me to send the response to the approval request.

Before sending the response to Approval flow using Flow Notification URL, I am making sure the my Approval is completed, so that it will not keep waiting for my response even we completed the approval flow. So I am setting status reason to Completed, Stage to Complete, Result with the Approval status label value(optional) and Status as inactive.

Before sending response to the Approval using “Flow Notification URI”, we need to prepare some json body. It accepts any key value pair, but I am making sure that I am preparing the response similar to the json structure when we approve the request from email request. Once response body is prepared, I am sending the post request to the “Flow Notification URI” with composed json body.

So my completed flow looks like below-

My flow is ready for testing-

When I am approving/ rejecting the request , My approval flow is resumed and completed, and I received mail as per my action –

When I navigated to the Approval request in my mailbox, It is showing that Others have already completed this request. Yay!!!… it worked.

So that’s it.

You can change the trigger of flows according to your requirement. For button click – change it to HTTP trigger and pass the required information on click of buttons.

Hope this will help…
Enjoy Ms CRM!!!

Follow on Facebook- FB: MSCRM16Tech

2 thoughts on “MS Power Automate : Act on Approvals directly from Dynamics CRM on column value change/Button click

  1. This is very cool – but is there a way to update only a single approval request to approved for an approval that has multiple approval request in the start and wait for response approval action that requires everyone to approve?

    Like

    • Thanks for your response. You can find the way to fetch the exact approval request with approver and add your logic to approve if everyone approved. Please check all the tables mentioned in the blog.

      Like

Leave a comment