Skip to main content

Building an Approval experience in Canvas Apps

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 !