Hello team,
This week I had to face one of the most common requirements in our business, an approval process and in true Power Platform I decided to use a Canvas App so our managers can approve the requests on the go.
As I started building the Canvas app I realised that it would be super cool to send push notifications so they are aware when they need to aprove something, this brought Flow into the equation.
But let’s start from the beginning:
Model Driven Requests App:
Entities not OOB:
Requests:
- This is the entity where I am tracking my requests, for now the Form is really simple, just a description field with some fields to track approval.
Approval Canvas App
Remember that you can begin working on your app from data, in my case, I decided to do precisely that and chose the Request entity.
This creates already a handy base to start working from, I only needed to filter down a bit more my gallery, so it only displayed the Requests that needed approval.
Here is the filtering code:
SortByColumns(Filter(Search(Requests, TextSearchBox1.Text, “name”),’Status Reason’ = ‘Status Reason (Requests)’.’Approval Needed’), “name”, If(SortDescending1, Descending, Ascending))
Tip: Remember that to compare based on Status Reason you need to find the following ’Status Reason (EntityName)’ this will enumerate the statuses in the OptionSet and let you compare it.
For the Details screen, I left it untouched apart from a button that I added at the end for approval.
Here comes Flow!
Now that we have both PowerApps ready, we have two more requirements that we need to meet.
Sending Push notifications to the Approvers:
In order to let our approvers know that they need to approve a request we are going to use the Push notification action in Flow.
Trigger: Using the OOB CDS connector, when a record is created
Condition: If the Approval Required field equals true and Approved By contains data.
Action: Retrieve the Approved By details from the User entity and send the push notification to them.
Tips when using the Push Notification action:
1. Remember that you need a user’s email address so you need to get that before you can send it, in our scenario we are using the Approved By lookup.
2. Make sure that you have added your App to the action connectors, otherwise you might be sending the notification to another canvas app.
Approving the request from our Canvas app:
Remember that we added the ‘Approve’ button the the Details screen, this means that the form on that screen is a read-only one. Rather than changing the form type we can trigger a flow on click of your button to update the status of the record for us.
From the Flow menu on PowerApps, choose “Create a new Flow”, this will open up the following screen and provide the context of our app to Flow.
To populate the Record Identifier we need to first click on Ask PowerApps and then Updatearecord_RecordIdentifier.
Also remember to update the status of the record
That’s all the configuration needed on the Flow side, the only thing left to do is to call it from the button with the following command:
PowerAppsbutton.Run(BrowseGallery1.Selected.Request)
Summary:
The business process that we explored in this post is a very common one, and I am sure you have seen it in multiple places.
By using the power and flexibility of the Power Platform, we have been able to provide an easy solution, including two Power Apps for two specific business cases but also increasing the development speed thanks to Flow.
Hope you find some of the tips useful, let me know in the comments below if you think there might be a better approach.
Thanks,
Mario