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.
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.
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.
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.
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.