Skip to content

Form Notification in D365 CE using JavaScript

In this blog, we will understand how to show notifications on forms of Model-driven app/D365 CE(CRM) using JavaScript.

We will understand how we can display Information, Error, or warning messages in the form of Model-driven apps.

Implementation

Syntax:

formContext.ui.setFormNotification(message, level, uniqueId);

Parameters

NOTE:

After Creating the form notification we have to clear the notification using clearFormNotification.

Syntax to clear form Notification:

formContext.ui.clearFormNotification(uniqueId)

Sample Code

var formCustomizations = {
    formNotifications: function (executionContext) {
        let formContext = executionContext.getFormContext();

        let infoMessage = "This is Information Notification."
        let errorMessage = "This is error Notification."
        let warningMessage = "This is warning notification."

        let infoId = Math.random().toString();
        let errorId = Math.random().toString();
        let warningId = Math.random().toString();

        //information notification
        formContext.ui.setFormNotification(infoMessage, "INFO", infoId);

        //error notification
        formContext.ui.setFormNotification(errorMessage, "ERROR", errorId);

        //warning notification
        formContext.ui.setFormNotification(warningMessage, "WARNING", warningId);


        //clear form notification after 10 seconds 
        setTimeout(function(){ 

            //clear information notification
            formContext.ui.clearFormNotification(infoId);

            //clear error notification
            formContext.ui.clearFormNotification(errorId);

            //clear warning notification
            formContext.ui.clearFormNotification(warningId)
         }, 10000);

       
    }
}

Explanation:

  1. The above code will display notification of type information, warning, and error on the form.
  2. I am clearing the notification after 10 seconds.

After 10 seconds these notifications will disappear automatically.

I hope you find this helpful!

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments