CRM Crate

Display a user notification in the Dynamics 365 application

Here we will learn to display a user notification in the Dynamics 365 application. Before we start, make sure to subscribe to CRM Crate so that you stay up-to-date in field of Dynamics 365 CRM.

Display a user notification in the Dynamics 365 application

Why do we need user notification in Dynamics 365 App?

Unlike the old form level notification (Notification displayed on record forms), we can now display an user notification for the overall Dynamics 365 model-driven app.

Consider a scenario where we need to announce or alert the system user globally whenever they are active on the Dynamics CRM, we can achieve this requirement using the addGlobalNotification client API reference.

Use addGlobalNotification client API reference in JavaScript –

Xrm.App.addGlobalNotification(notification).then(successCallback, errorCallback);

Displays an error, information, warning, or success notification for an app, and lets you specify actions to execute based on the notification.

JavaScript snippet code for displaying notification using addGlobalNotification

Below is the JavaScript snippet executed during the “OnLoad” event of an entity form.

//CRM Crate - JavaScript Snippet
function CallMethod (executionContext) {

//Creating Object Required By API.
var TriggerActionObj =
actionLabel: "Learn more",
eventHandler: function () {
var NotificationObj =
type: 2,
level: 4,
message: "Please Subscribe To CRM Crate So That You Stay Up-To-Date In Field Of Dynamics 365 CRM!",
showCloseButton: true,
action: TriggerActionObj

//Calling addGlobalNotification client API.
function success(result) {
console.log("Notification created with ID: " + result);

// More code here
function (error) {
// handle error here

Below are the details of parameters required by the addGlobalNotification client API.

  • action: (Optional) Object. Contains the following values:
    • actionLabel: (Optional) String. The label for the action in the message.
    • eventHandler: (Optional) Function reference. The function to execute when the action label is clicked.
  • level: Number. Defines the level of notification. Valid values are:
    • 1: Success
    • 2: Error
    • 3: Warning
    • 4: Information
  • message: String. The message to display in the notification.
  • showCloseButton: (Optional) Boolean. Indicates whether or not the user can close or dismiss the notification. If you don’t specify this parameter, users can’t close or dismiss the notification by default.
  • type: Number. Defines the type of notification. Currently, only a value of 2 is supported, which displays a message bar at the top of the app.

Validate the user notification in the Dynamics 365 application.

Deploy the above JavaScript snippet and navigate to the Dynamics 365 CRM to validate the application level user notification.

As shown in the above image, the application level notification has been displayed in the Dynamics 365 CRM.

Thus we learned to display a user notification in the Dynamics 365 application.

4 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!


Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.