This is another new feature of Dynamics CRM 2013. While in previous versions, we used to use JScript alerts to bring up field specific messages on forms, now we have two new functions available:

setNotification(“message”);

and

clearNotification();

So how do we use then, and what do they do?

First off, let’s bring up a message on a field if a condition is met, or clear it otherwise:

function SetCustomNotification(controlName, controlMessage)
{
    var field = Xrm.Page.getControl(controlName);
    var condition = [evaluate your condition here];
    if (condition)
    {
        field.setNotification(controlMessage);
    }
    else
    {
        field.clearNotification();
    }
}

Pass in strings for controlName and controlMessage.

Set your function on either the onChange event of the field, or on the onSave event of the form. If you set it on form save, it’s a good idea to stop the save if the condition fails and the message comes up.

And the end results is your custom message showing as below:

image

Enjoy!

Advertisements