Global Notification in Dynamics 365 Unified Interface App [Preview]

Here’s a great feature to add a warning/error notification which is scoped globally unlike setFormNotification() which is commonly used and remains within a form itself.

Xrm.App.addGlobalNotification(notificationObject).then(success, error); serves this purpose. Let’s see how –

Disclaimer: Please be aware this is a preview feature yet and I’ll update on this post once this is out of preview.

This is only available for the Unified Interface.

Scenario

Let’s say you have opened an Account form and you want to warn the user in case they are working remotely with someone and might have their screen shared. You want to show a message like this –
globalNotif

And even if they navigate away from the form, it will remain on the screen since it’s scope is global.
navigatedOtherPlaces

Or, user can chose to close it manually which appears at the end of the strip on top-right corner.
canCloseIt

You can also optionally add a button and make it navigate to another URL in case you want to share more info with the users (In my example, I redirected to https://www.microsoft.com/en-in/) –
learnMoreButton

Example

Xrm.App has 2 methods to do the needful –

Xrm.App.addGlobalNotification(notificationObject).then(success, error) & Xrm.App.clearGlobalNotification(notificationObject).then(success, error)

In my scenario, I want to trigger the warning message as soon as the user wanders into one of the Account records. So, in my case, I’ve registered the method onLoad of the Account form itself.
Here’s the code in my JS file for the same –

Some notes before we proceed with the code –

  1. type in the notification object is supported as 2 at the moment and no other types are supported.
  2. The levels are as below
    1. Success
    2. Error
    3. Warning
    4. Information

account = {
globalNotification: function () {

var learnMoreAction =
{
actionLabel: “Learn more”,
eventHandler: function () {
Xrm.Navigation.openUrl(“https://microsoft.com”);
}
}
var notificationObj =
{
type: 2,
level: 3, //warning
message: “Please make sure you are not sharing your screen!”,
showCloseButton: true,
action: learnMoreAction
}

Xrm.App.addGlobalNotification(notificationObj).then(
function success(result) {
console.log(“Notification created with ID: ” + result);

// More code here
},
function (error) {
console.log(error.message);
// handle error here
}
);
}

};

I’ve registered the Function as account.globalNotification. You can directly use globalNotification is you are writing function directly as function globalNotification() {}

fnAdded

This notification remains App-wide unless closed by closed by a user of closed using clearGlobalNotification method as mentioned by Microsoft.

Source documentation by Microsoft is here – Xrm.App

Since we are transitioning into Unified Interface, here are some other related posts that you may like looking at –

  1. D365 Quick Tip: Why BPF wouldn’t appear in D365 Unified Interface?
  2. Fix Ribbon icons on the Unified Interface in D365 CE
  3. Change the Unified Interface App Icons
  4. Unified Interface App URLs – 3 different ways

Hope this helps!!

Advertisement

One thought on “Global Notification in Dynamics 365 Unified Interface App [Preview]

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.