Dynamics 365 – In-App Notifications – Send App Notifications To Users

With the new features of Model Driven Apps in Dynamics 365, the user can now get fancy in-app notifications. The users will see a notification pop-up in their apps based on the condition they want(creating a record, updating a field, deleting a record etc. basically anything you want) and this notifications can also lead users to the records.

App notification with a single action.
App notification with multiple actions.Notification with a block of text that includes an inline link.Notification with a block of text that includes an inline link and bold text.

This is a preview feature and you need to enable it from developer console of your browser. Don’t worry, it is some very easy steps.

Open your environment, then open your app where you want to enable this feature. Click on the F12 key to open the developer console. Paste this below code to your console and hit enter to execute it.

fetch(window.origin + "/api/data/v9.1/SaveSettingValue()", {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
AppUniqueName: "msdynce_saleshub",
SettingName: "AllowNotificationsEarlyAccess",
Value: "true"
})
});

You can find the unique app name by opening the app designer and clicking on the properties tab as shown in the image below.

When you publish your app, you should be able to see a bell icon on top right of the app as shown in the below image.

To send a notification, you will create a record in the “appnotification” table/entity. Since this is a basic record creating, createRecord API, Web API and Power Automate Flow all are suitable for this.

If you are using Power Automate Flow, you will add a new row to the Notifications table like the image below.

Or you can use the createRecord API to send a notification.

var systemuserid = "Guid of the user";
var notificationRecord =
{
  "title": "Welcome",
  "body": "Welcome to the world of app notifications!",
  "ownerid@odata.bind": "/systemusers(" + systemuserid + ")",
  "icontype": 100000000, // info
  "toasttype": 200000000 // timed
}
// Create notification record
Xrm.WebApi.createRecord("appnotification", notificationRecord).
  then(
      function success(result) {
          console.log("notification created with ID: " + result.id);
      },
      function (error) {
          console.log(error.message);
          // handle error conditions
      }
  );
Notification with a custom icon.

ColumnDescription
TitleThe title of the notification.
OwnerThe user who receives the notification.
BodyDetails about the notification.
Icon TypeThe list of predefined icons. The default value is Info. For more information, go to Changing the notification icon later in this topic.
Toast TypeThe list of notification behaviors. The default value is Timed. For more information, go to Changing the notification behavior later in this topic.
Expiry (seconds)The number of seconds from when the notification should be deleted if not already dismissed.
DataJSON that’s used for extensibility and parsing richer data into the notification. The maximum length is 5,000 characters.
Notification Table
Icon TypeValue
Info100000000
Success100000001
Failure100000002
Mention100000003
Warning100000004
Custom100000005
Changing the notification icon

For more info, check the official docs link: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/send-in-app-notifications#send-basic-in-app-notifications-by-using-the-web-api?WT.mc_id=BA-MVP-5003699

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s