Enable Form Notifications

The question was asked!, how can I enable the Form Notifications on Microsoft Dynamics CRM 2013.
The notification section is not available on all the forms, like custom entity forms, and I want to add notifications to those forms with other validation on fields events.

using the browser developer tools on the forms where the notification is available, i found the following element “crmNotifications” that will display the notification and show the message

///////////////////////////////////////////////////////////////
// Enable Form Notifications
///////////////////////////////////////////////////////////////


function Notifications() {

    var crmNotificationsDiv = document.getElementById("crmNotifications");
    crmNotificationsDiv.style.display = "block";

    Xrm.Page.ui.setFormNotification('Notifications Error', 'ERROR', '1');
    Xrm.Page.ui.setFormNotification('Notifications Warning', 'WARNING', '2');
    Xrm.Page.ui.setFormNotification('Notifications Info', 'INFO', '3');
    alert('Completed Notification!');
}

function NotificationMsg(FieldName, Msg, TypeMsg, MsgId) {
    var crmNotificationsDiv = document.getElementById("crmNotifications");
    crmNotificationsDiv.style.display = "block";

    Xrm.Page.ui.setFormNotification(Msg, TypeMsg, MsgId);
    Xrm.Page.ui.setFormNotification(Msg, TypeMsg, '2');
    Xrm.Page.ui.setFormNotification(Msg, TypeMsg, '3');
    Xrm.Page.getControl(FieldName).setNotification(Msg);
}

function clearNotifications(FieldName, MsgId) {

    Xrm.Page.ui.clearFormNotification(MsgId);
    Xrm.Page.ui.clearFormNotification('2');
    Xrm.Page.ui.clearFormNotification('3');
    Xrm.Page.getControl(FieldName).clearNotification();

    var crmNotificationsDiv = document.getElementById("crmNotifications");
    crmNotificationsDiv.style.display = "none";
}


The code will help you to add a message on a single line or the same message on all 3 lines, also you can assign the message to a specific field, the clearNotifications as the function indicates will clear all the messages on the notifications section.

I been using the following functionality, with my custom entity forms and it works fine, a little more work need to be implemented but that will be implemented in the near future.

hope you can use the following code!, and also please remember that the code is unsupported and can stop working with the coming roll up or Service packs updates.

Contact us for a free consultation if you have any further questions.

Abe Saldana.

Leave a Reply

Your email address will not be published. Required fields are marked *

Blue Captcha Image
Refresh

*