Views:

Before CRM 2013, if you want an alert on a form within the browser, the only method available was the standard JavaScript alert. i.e.

alert("This is a standard javascript alert.");

From CRM 2013 Microsoft introduced an additional alert method in CRM, Xrm.Page.ui.setFormNotification. This method allows three different types of alerts: error, information, and warning. Instead of popping a window open over the current window, this embeds the notification in the CRM page itself.

Set Button in Notification:

To add new button in the notification we can use one reference JavaScript file i.e. Notify.js

For javascript reference file is https://notifyjs.codeplex.com/SourceControl/latest

function Notify() {

Notify.add("Get the Company Details", "INFO","id", [{

text: "link", text: "Company", callback: function () {

window.open("https://www.mtccrm.com");

}

}])

}

We can use this code onload / onchange and onsave events it will be shown as below

clip_image002

If we click on the company button it will be open a new window.

Remove Notification

We can Remove one or all notifications from the custom notification bar. If an ID of a notification is passed into below function, that notification will be removed. If no ID is passed to this function, all notifications will be removed.

// Remove a single notification

Notify.remove("id");

// Remove all notifications

Notify.remove();

Notification in Mscrm:

· To Display Form Level Notifications we can use this method. So, every new notification will be displayed on the top. Users can scroll down for the older notifications.

· To Display all notification in form use below code

//Notifications in Form level

function callFormNotification() {

Xrm.Page.ui.setFormNotification("Form Error Notification", "ERROR", "1"); Xrm.Page.ui.setFormNotification("Form Warning Notification", "WARNING", "2"); Xrm.Page.ui.setFormNotification("Form Information Notification", "INFO", "3");

}

This function is added on form onload, result will be displayed as below.

clip_image004

Clear Notification

To clear the notification in the form use below code, if ID of a notification is passed into below function, that form notification will be removed.

//Clear Form Notifications

function clearFormNotification() {

Xrm.Page.ui.clearFormNotification("1");

}

Result will be displayed as below

clip_image006