I have worked with Microsoft Dynamics CRM for a few years now. Every once in a while, I will run into one of those tricks or handy snippets of code that I wish I found a long time ago. In the past, I have had business cases where I needed to alert the end user to something on the form or a piece of data that they should pay particular attention. I have done everything from changing the colors of labels to throwing alert boxes. I have never been fond of any of them. It just didn’t feel like it fit.

My new found friend is the ‘crmNotifications’ div tag. I realized this little trick by stumbling across another blog. Now, before I show you how cool this is and how to use my new friend, I should preface that it is technically non-supported. That means that a rollup or upgrade could break your functionality. With that said, it allows for a better user experience and is incredibly easy to use.

As you can see, you can easily include a message at the top of each form. These messages can be based on any business logic as it will be implemented through the javascript.

To implement this:

  1. Navigate to the ‘Form Properties’ of the appropriate entity main form in which you would like to add this.
  2. On the ‘Form Properties’ window, on the event tab, add a library to the ‘Form Libraries’.
  3. Double click on the new library you just added to open it in the ‘Web Resource Content’ editor. We are going to add an ‘Form_onLoad’ function with no logic in it yet.
  4. Next we are going to create a second function called ‘set_Notification’. Below is the code:

    function set_Notification(level, source, message) {var notificationsArea = document.getElementById(‘crmNotifications’);if (notificationsArea == null) {alert(‘div not found’);return;}

    //critical = 1, warning = 2, info = 3

    notificationsArea.AddNotification(‘mep’ + level, level, source, message);

    if (message == “”) {

    notificationsArea.SetNotifications(null, null);



  5. Next we need to include a call to our set_Notification method. This can be done based on any appropriate business logic. I am simply going to call this with the different levels of alerts.

    set_Notification(1, ‘source’, ‘Wow. This is a critial issue. Run for safety.’);set_Notification(2, ‘source’, ‘Just a warning message. It barely even broke the skin.’);set_Notification(3, ‘source’, ‘Informational message. Please carry on as you were.’);
  6. The last piece is to wire up our function to the onload event of the form. This is done in the ‘Form Properties’ window under the ‘Event Handler’ section.

The logic that I have shown is specific to CRM 2011. This same concept can be performed in CRM 4. The syntax is a little different for how you set the text of the notification message. If you are interested, let me know and I can get you the code.

Like this post? Share it!