Skip to main content

Building an Approval experience in Canvas Apps

Headshot of article author Mehdi Slaoui Andaloussi

In a previous blog post, we used a custom connector to access a set of Common Data Services APIs to create a Business Process Flow component within Canvas app. Similarly, we can extend the Approvals connectors functionality by exposing additional operations via a custom connector.  Specifically, we will use a set of APIs to list received and sent Approvals as well as approve and reject Approvals from within a Power Apps canvas app.

You can download the app here: https://aka.ms/approvalsapp
Get the swagger file for the Approval custom connector here: https://aka.ms/swaggerapproval

To retrieve sent and received approvals, we use the GetApprovals operation available in our custom connector:

UpdateContext({ top:10, environment:"72e87f56-e215-43d4-8883-5cf7ff5550f5", receivedFilter:"properties/userRole eq 'Approver' and properties/isActive eq 'true' and properties/isDescending eq 'true'", sentFilter:"properties/userRole eq 'Owner' and properties/isActive eq 'true' and properties/isDescending eq 'true'" }); ClearCollect(Received, Flow.GetApprovals(environment, {'$top':top, '$filter':receivedFilter}).value); ClearCollect(Sent, Flow.GetApprovals(environment, {'$top':top, '$filter':sentFilter}).value);

 

To approve or reject an approval request, we use the SetApprovalResponse:

Custom Connector Deployment

Before creating the custom connector using the above swagger file,  you will need to register an application with the Azure Active Directory service. For a refresher, read the following article here: https://docs.microsoft.com/azure/active-directory/azuread-dev/v1-oauth2-on-behalf-of-flow#register-the-application-and-service-in-azure-ad.  While going through that process, grant permission for the flow service:  

Ensure Approvals.Manage.All & Approvals.Read.All are checked.

Finally, download and import the swagger file for the custom connector.  Enter Client Id, Client Secret and Resource URL: https://service.flow.microsoft.com/.

You can now import the app and give it at try !

Disclaimer

The assets / samples provided in this blog are not supported by the Power Platform product team (which is true for all tools available in this GitHub repo). We are a small team in Engineering who built this community sample solution for anyone to use and modify as their own, made available to customers on an as-is basis via an MIT license. It’s possible you might run into some issues, such as installation problems, authorization issues, or bugs in the apps and flows within the solution. If you encounter an issue, please raise it in the issues tab of the GitHub repo.