A few years back, my friend Marco posted a way to leverage CRM's in-line alert display to show a custom error message leveraging the default error window. Wondering if this approach would work on 2011, I found that the Notification area still exists in 2011 and there are some methods exposed via the HTC file that allow for easy manipulation.
The following code is, technically, unsupported and there are no guarantees that this code won't change in the future, but it works. If you add the following code to a web resource and then tie the set_alert function to the onchange event of a field, you can see it operate. The second call will wipe out the displayed notifications.
var mep=1;
function set_alert()
{
var notificationsArea = document.getElementById('crmNotifications');
if (notificationsArea == null)
{
alert('div not found');
return;
}
if (mep==1)
{
notificationsArea.AddNotification('mep2', 2, 'source', 'Warning message');
notificationsArea.AddNotification('mep3', 3, 'source', 'Info message');
notificationsArea.AddNotification('mep1', 1, 'source', 'Critical message');
mep=2;
}
else
{
notificationsArea.SetNotifications(null, null);
mep=1;
}
}
When you have multiple notifcation messages, they will be sorted by the severity as shown here.
Matt Parks