Managing Approvals Power Automate

 

The Power Automate web, Power Automate Mobile app, Microsoft Teams, and your preferred email client all offer access to the platform's excellent approval system. However, there are some circumstances in which you might want to grant permissions through a different system while maintaining the Power Automate approvals.

Assume that you have a Power App, SharePoint list, or other app that generates approvals. You might wish to require approvers to access that app to offer approvals in addition to allowing them to complete the approval as part of Power Automate. Assume that the data storage in this instance is SharePoint.

The flow might be set up in this case to update the SharePoint list with the approval status so that the approver may see the result inside the app. However, the workflow wouldn't be updated if the user has approved the item in the SharePoint list. The user (or another approver) might still use Outlook, Teams, or Power Automate to carry out the approval. Multiple approvals for the same event would arise from this. Very bad!

One way around it is to use the Create and approval and Wait for an approval actions. There are a few key differences that are required in the process.

  1. Create an approval is used to kick-off the approval
  2. The Approval ID needs to be stored somewhere (e.g. SharePoint list)
  3. A second workflow is needed to wait for the approval to complete using the Approval ID captured in step 2
  4. Another workflow is needed to capture the event of the approval happening in the app in order to cancel the approval process

Let’s look at the solution in more detail. In the scenario below, I’m using a SharePoint list as my storage for the approvals. All I really care about is the Approval ID.

Starting the approval

As mentioned in steps 1 and 2, the process begins by invoking a Create an approval action and storing the resulting Approval ID in a data source.

In this case, the data source is the SharePoint list.

Waiting for Approval

Once the approval has been initiated and the Approval ID is known, it can be used to wait for the approval. For simplicity, I’m using a workflow that is triggered by the SharePoint item creation itself (step 3).

This workflow will run for up to 30 days and update the SharePoint item with the status once completed. So far, the solution is not much different from the Start and wait for an approval approach. The next flow is where things get more interesting.

Canceling an event when approval is granted via the App

In order to prevent approvals from being granted twice, it is necessary to create a different workflow to capture the permission outside of the Power Automate workflow and to cancel the request. Internally, Dataverse stores approval information in the Approvals table. Without directly dealing with the approval request, the status of the approval can be updated by knowing the Row ID (Approval ID). Because of this, it's crucial in this workflow to update the Stage, Status Reason, and Status of the approval request using the Dataverse Update a row action in addition to marking the approval status in the SharePoint list.

Once the action completes and an approver attempts to invoke an approval, they message will change to show the stage based on this update.

Comments

Popular Posts