Tuesday, February 5, 2013

Custom CRM 2011 Form Notifications for UR12

[UPDATE: 2013.04.12 I added some additional tricks to this code, at the bottom.]

Before Update Rollup 12, it was relatively simple to use the original “form alert” hack (seen here, here, here, and here) to produce custom, inline alerts and notices for the end user.  It’s a great feature of the form, and I wish I knew why using it is unsupported.

Alas, many realized that these customizations would be undone by Update Rollup 12, and indeed they have.  So, allow me to show you what appears to be the “Microsoft” way of accessing the new form notification system.  The added bonus is that this method requires no additional libraries or external references, and should be cross-browser.  (Disclaimer: the following information was not released or documented by Microsoft; I discovered it after a few hours of pouring over Developer Tools in IE10.)

The original hack could never have been cross-browser, because it relied on the “htc” behavior file which backed the original “crmNotifications” element.  Fortunately, these functions haven’t changed… just moved to a new home.  Here’s the old way (pre-UR12):

var notificationsArea = document.getElementById('crmNotifications');

notificationsArea.AddNotification('noteId1', 1, 'namespace', 'Message.');

And here’s the new way (post-UR12):

var notificationsList = Sys.Application.findComponent('crmNotifications');

notificationsList.AddNotification('noteId1', 1, 'namespace', 'Message.');

Both examples do the same thing in their respective CRM 2011 revisions.  This customization remains as unsupported as it ever was; however there is relatively little danger in using it.

Here are some additional tricks you can use:


That will reset the notifications array with an empty set.  Also, you can hide the notifications area by using: