When assigning critical Tasks to different users or teams, you probably want to know when they have finished them! You probably also do not want a mobile push notification disturbing you in your work. Luckily Model-Driven Apps provide a way to notify users! In this post I show you how to accomplish this using Power Automate and the In-App Notification center of Model-Driven Apps.
But what I find really cool, is that you can create a richer card for your notification. You do so by combining the body and data column of the notification table. In the body you can use some Markdown to style your message. In the data column we can add json to add actions in the notifications. Actions allow you to add navigation urls to for example a form in your app. Building these is a breeze with the In-App Notification Builder in the XrmToolBox.
Following up on a task
This blogpost builds upon my previous blog post in which I show how to notify a user by posting an Adaptive Card to teams. It is part of a case where a customer wants a new screen for his broken phone. The user who sends the screen does not use our Model-Driven App often, but when he completes the task, we do want to be notified!
First things first, we need to enable our application for In-App notifications. This we have to do inside the App Designer of the Model-Driven application. Go to settings and under the Features tab you can find the setting.
Now let’s open the In-App Notification Builder and get cooking. For the Title of the Notification, we set “Task Completed”. If you want a more expressive name, you can of course change this in the Power Automate formula. The body is a simple text explaining that the Task is **completed**. Use the Bold button to help you write Markdown in your Body text. The Markdown notation for Bold are the stars around “completed”.
The Toast Type lets you select if the notification should show immediately on the form if the User is already in our app. If you choose hidden, it will only appear in the notification center. For this Notification I choose the Info icon, but you can choose others, or even select a webresource for a custom Icon. For reference below is the complete notification that we are going to build. Do check out the Preview feature in this screenshot, this is also how it will look inside our app!
Create the Actions and get the code
Now that we have the basics covered, we want to add 2 actions to easily navigate to the relevant records. One to go the Case and one to go to the Task. Add these by using the actions in the bottom of the tool. We can define the text of the action and if it needs to open inline, as a dialog or in a new window. The tool also lets you define specific types like URL, Form or Custom Page. But in the end, they will all generate a URL. I prefer to just build the URL in Power Automate, but it can help you build your URL. Keep in mind that some parts are hardcoded and will need changing for other environments.
Prepare in Power Automate
Let’s go to our flow! As mentioned in the introduction I am extending a flow of my previous blogpost. When a Task is created, we send an Adaptive Card to a Teams user. When that user indicates the Task is complete, the Flow continues, and we want to notify the owner of the Case the Task is related to.
First, start with building the URLs for the 2 actions in our notification. The “Create the task record URL “is already there as that is also inside the Adaptive Card. We create a second compose for the case record URL. To dynamically grab the environment URL of the Model-App I use a combination of the “OData Id” URL and the uriHost() function. The uriHost will grab the “base” part of the URL, so we can extend upon it. See this other blogpost where I explain this in a little bit more depth.
Now we can use these Compose variables to inject into the Data part of the Notification. I like to use another Compose action for this, as this will help me stay organized. Copy and paste the code from the In-App Notification Builder into the compose action and change the google.com URLs to the corresponding output of the Composes above.
Create the In-App Notification
Now it’s time to create the actual Notifications record in Dataverse. Again, copy and paste the information from the Notification Builder and we are almost done! The only part we need to change is the Owner of the Notification record. the Guid placeholder we change to the owner of the case. This is part of a Lookup field, so we pick the actual value where the Guid is stored.
That’s it! You can now test the Cloud Flow and a nice Notification with actions will appear in your Model-Driven Power App.
I think it’s neat that we have all these features we can use in the Power Platform. This is definitely a productivity hack for the users of your App. You only have to make sure to do this consistently. If a user expects to be notified that Tasks are finished, they might not check the actual record anymore 😉