Form and Fields Notification in Dynamics 365 Part 1

Dynamics 365 provides different ways to implement client side notifications, we can implement them in different level. In this article we are going to provide different methods which can be used to work with notifications.

This method is used to work with individual control over entity form. We can make use of this method to implement our client side data validation and display error notification to user for example let’s say we want to implement a validation into mobile number field of account entity and we want to make sure user should not enter text value in mobile field. This is just an example but it can be used in actual requirement similarly. So let’s use setNotification method with mobile field using following code:


As we can see it takes two parameter:
message:- The notification that we want to display to user.
uniqueId:- The unique id associated to notification.

So to implement our validation, we can use following method:

function OnChange_telephone()
var mobile=Xrm.Page.getAttribute("telephone1").getValue();
Xrm.Page.getControl("telephone1").setNotification("Please enter correct mobile number","101")

We can bind above method onchange of telephone1 field in account entity:

If user will enter some text under telephone field it will show the error notification like following:


This method is used to clear notification which is set using setNotification method with the help of unique notification id. For example if we want to remove notification from earlier example it can be like following:



This method is used to set notification at form level. This is very useful if we want display a consolidated notification or may be want to remind user something about current record or want to display some error message at form level, we can use this option.

We can use following statement for form notification:

Xrm.Page.ui.setFormNotification(message, level, uniqueId);

Where message is the notification that we want to display to user and level represent type of notification that we want to show. We can pass any of the following three parameters:

ERROR:- To display error notification to user which will have a Red Cross sign.
WARNING:– To display warning to user and it will show system warning icon.
INFO:– To display information to user with system info icon.

Let say we have one flag (two option set field) over account entity which stores information if customer submitted verification document or not. If verification document is not submitted we want to display reminder to customer, so we can use code like following:

function setDocumentNotification() {
    var isdocumentsubmitted = Xrm.Page.getAttribute("new_isdocumentsubmitted").getValue();
    if (!isdocumentsubmitted)
        Xrm.Page.ui.setFormNotification("Please submit your verification documents", "INFO", "2001");

We can call above method on account entity form onload and when user will open it will display notification based on the flag like following:


This method is used to clear notification at form level. We can pass unique id of the notification and clear it like following:


We can add above code in our existing web resource. In next article we will discuss some more notification methods.

Stay tuned for next article on Dynamics 365 notifications !!!

5 thoughts on “Form and Fields Notification in Dynamics 365 Part 1

  1. Pingback: Form and Fields Notification in Dynamics 365 Part 1 - Microsoft Dynamics CRM Community

  2. Graeme Donnell

    Hi, do you know if its possible to include fields from the current record in the Form Notification.

    For example, I have a requirement where the record has a Date Closed field and the client would like the form notification to read

    This Establishment closed on “DateClosedField”

    1. HIMBAP Post author

      You can use java script to read value of the field and then form a string message with the value of this field and then display that message on the form notification.
      for example

      var value=formContext.getAttribute(“Field”).getValue();
      var msg=”Some message:”+value.toString();

      It will work. thanks


Leave a Reply

Your email address will not be published. Required fields are marked *