Form and field notification are new to CRM 2013 and there have already been quite a few posts about these. I was playing around with form notification and wanted to display an Info notification that would automatically go away after a few seconds. This is a common nice to have for informational messages.
This actually was pretty simple to achieve using the standard setTimeout function. Below is the generic script for achieving this.
var BNH = BNH || {}; BNH.FormNotification = (function() { return { setAutoRemovedNotification: function (message, id, displayDurationSeconds) { Xrm.Page.ui.setFormNotification(message, 'INFO', id); setTimeout(function () { Xrm.Page.ui.clearFormNotification(id); }, displayDurationSeconds * 1000); } }; }());
Invoke this with the code below.
BNH.FormNotification.setAutoRemovedNotification('Hello world!', 'MY_MESSAGE', 5);
The only minor issue is that by default the notification is displayed inline with the form. Form content is therefore pushed down when the notification appears, and moved up when it is removed – which may slightly disrupt the user. It’d be nice to apply some CSS to float the notification on top of the form content.