So couple of Months back, we had a business case where we were doing a demo for a solution for Reports Request. Now whenever an Analyst completes a report it should go through an approval cycle. For the App we were using Power Automate Approvals. Now everything was fine the Approvals will go and works.
Then the customer came up with a demand to have the approvals also visible within the App and that was tough, we looked for different ways. Initially we thought of two ways
- Get the approvals values from the CDS (restricted) entities
- Or show the approval within a iFrame in the canvas app
The first one was unsuccessful as we didnt get those meta data, and iFrame failed because Microsoft Authentication doesnt support iFrame and redirects.
Till couple of days back i found the solution. the in famous Custom Connector.
So follow along, if you want to learn how.
- Create a Custom Connector using the Customer Swagger File. Download the file from GitHub.
- Lets go to Create a custom Connector
Once you have added the Swagger File, most of the things will be Populated Automatically.
Now go to Portal.Azure.com and lets create an app registration for this connector. Select the Azure Active Directory and then select App Registrations and click New.
Once the app is completed, go to the client secret setting of the app and generate a new secret
Important thing to note here is as soon as the secret is generated copy it and save it as you wont be able to access it again.
Now the rest of the information we need is available in the app overview blade
You will need Application ID most importantly. In the App API Permissions settings go and add the permission for Flow and Grant Permissions for approvals.
Additional you can provide Admin consent for these apps if you like. I will write a blog about Admin Consent on permission some other day.
So with that done, lets go back to our custom connector secreen.
You can fill the information as you like in the General section,
In the Security section, make sure to select O Auth 2.0 and Azure Active Directory
Fill in all the other details from the Azure App we just created, one important piece the Resource URL should be https://service.flow.microsoft.com/.
Other than that you can modify the Default values of input Parameters for your two actions. Specially you need to change the environment_name variable.
That’s Its, Update the connector and create a custom connection out of it and test your Custom Connector. In the example below i Tested get approvals connection
And thats it! you can use the actions in your Flow, Power app to get the approvals.
For this blog, i am using the Approvals App created by Microsoft and you can download it from here: https://aka.ms/approvalsapp
You would also need to update the environment ID within your app at almost 3 locations one is on Home Screen and the other Two is at the Refresh button. With everything set this is how your app will look like.
There is nothing Fancy in the app, to explain. We are storing the result in a collection after calling the Flow and the Flow looks like this. You will get flow as part of the approval app and just need to update the econntion.
The Flow stores the data in collection and we are using a Gallery to display the result. The flows have two acitons
- SetApprovalResponse – Send a response to Approval Rrequest
- GetApprovals – Get you all the flows in the environment (you can modify the query to get approvals even when you are not an owner)
I hope this blog explained you how to get Power Automate Approvals witin your Canvas App