Model Driven App In-App Notifications

Following up on our recent post on the enhancements being deployed in the 2022 Wave 1 release from Microsoft, we want to discuss one of those new features – In-App Notifications for Model-Driven Apps.  You can read more about this feature from Microsoft here.

We recently were able to play around with the In-App Notifications and wanted to share some of the gotchas and lessons learned while doing so.

Setup and Configuration

Initially, Microsoft outlined enabling this functionality by running the below JavaScript leveraging developer tools on your browser by hitting F12.

Thankfully, Microsoft quickly updated this and added a new yes/no toggle in the model-driven app settings (steps outlined here). At the time of this blog, the Microsoft article states to switch to the Upcoming tab of the model drive app settings, but in my test environment, I see it on the Features tab.

Note this functionality is turned on in a app by app basis and therefore isn’t currently an overall environment setting.

Let’s See it in Action

Once enabled, you’ll be able to use the Client API, Web API, or Dataverse SDK as outlined in the Microsoft article above that shows how to enable the functionality.

For the non-coders, this functionality can also be leveraged using Cloud Flows via Power Automate. Here’s a simple flow that was created to test, that simply runs when an Opportunity is modified and posts a notification to that user who modified the Opportunity (not a very useful flow, but gives us what we need to test).

The secret sauce is basically creating a record in the “Notification” table, and assigning it to the correct user to see. This link details what the different fields are that you can set, what their default values are, as well as what each value means for the notification the user would see.

Note that when selecting the Notifications entity for the “Add a new row” step, you’ll see two tables named Notifications. You’ll want to select the first one as the second one seems to be an internal use only table.

Also, note that I updated the body of the notification to have a function that provides me the name of the user who modified the Opportunity versus the GUID of the user. By default, if you select “Modified By (Value)” you’ll get an auto-created expression like this:

@{outputs(‘Retrieve_the_Opportunity_details’)?[‘body/_modifiedby_value’]}

Removing the brackets {}, the @ character at the beginning, and adding in @OData.Community.Display.V1.FormattedValue just before the last single quote gets you this expression that you can paste into the Expression popout in Power Automate:

outputs(‘Retrieve_the_Opportunity_details’)?[‘body/_modifiedby_value@OData.Community.Display.V1.FormattedValue’]

As far as what the end-user sees, after notifications are enabled for a model-driven app, a bell icon will appear in the top right corner next to the settings gear icon. Clicking this will take you to the Notification Center.

When an Opportunity is updated, I’ll see the notification appear on my page since my Cloud Flow was set to create a notification with Toast Type of Timed. If the Toast Type was Hidden, you’d only see the notification bell icon number increment indicating there’s a new notification that the user would need to click into in order to see it.

Clicking the bell icon takes the user to the notification center, where they can 1) view the details of all notifications received, 2) clear out notifications individually or dismiss all, and 3) go to their personal notification settings to set their toast duration or turn toasts off altogether.

An admin will also have the ability to search the Notification table (either in the classic advanced find, or the new modern advanced filters) to find all notifications that haven’t been dismissed. Once a user dismisses a notification, it deletes the record from the Notification table.

Gotcha

The toast functionality of the notification seems buggy at the moment. It doesn’t always appear when the notification is created (via the Cloud Flow in this example). Sometimes it pops up automatically, and other times I need to refresh the browser or navigate to another area to see the toast appear and bell icon number to increment. This seems pretty crucial functionality to a notification and one of the big reasons why I wouldn’t recommend rolling this out just yet.

Overall this feature is promising but seems as if Microsoft still has a few kinks to work out. Until then, be educated on what this functionality currently can and cannot do, and make a decision on if it makes sense to roll out for your organization in its current state.