Using JavaScript is a quite common approach for client side validation and interaction on the Microsoft Dynamics CRM forms. In many occasions we need to notify or warn the user about a condition or situation depending on certain values of some fields in the form. Normally you would use a JavaScript alert to show a dialog with the warning notification, this can be quite annoying for the users if they keep continuously facing this warnings.
Microsoft Dynamics CRM has a internal nice way of doing it by adding a yellow background warning message on top of the form, like in the picture below.
After a question on the Dynamics CRM Forums I’ve been playing a little bit with this an created a small JavaScript snippet that can be used to enable our client side code to achieve the same effect showing warning messages.
The code consist of a function called ‘addNotification’ that allows you to add a new notification message with the same visual style as the Dynamics CRM ones. This function uses the Notification area that is included on an Entity form to display the message with the same visual style.
Once you have added the declaration of the ‘addNotification’ function to the OnLoad you can call it either from the Onload or any OnChange event to provide warning messages to the user without using the typical JavaScript alert approach. The result will be the same as the one shown in the screen capture below.
Utilizar JavaScript es una técnica bastante común en Microsoft Dynamics CRM para realizar
Thank you very much. Copy, paste, and working, not easy to find code like that around…
It looks like a very nice idea that will save few user clicks then it would be great if we know where to find the source code for this addNotification function..
Great post, thanks.
Here’s Dejan Dular usage of the functions:
http://a-crm.blogspot.com/2009/07/show-custom-notifications-on-microsoft.html
[…] http://box5254.temp.domains/~marcoamo///blog/show-custom-warning-messages-on-microsoft-dynamics-crm/ […]
I updated the code to work with the latest Polaris release. The changes can be found on my blog at http://www.robotii.co.uk/2013/01/getting-notifications-to-work-in-crm-2011-ur12
Feel free to update your post with the changes I’ve made.