Olá!
Iniciando este blog, demonstrarei como adicionar notificações nos formulários do CRM na versão 4.
Algumas entidades nativas da ferramente demonstra notificações para alertar algo para o usuário, melhor do que um alert() do javascript.
Abaixo segue o código para adicionar as notificações
function InsertNotification(title, text, informationType) {
//define attributes of the first div called notifications
var divNotifications = document.getElementById('Notifications');
var childNodesLength = divNotifications.childNodes.length;
var order = 0;
if (childNodesLength > 0) {
order = childNodesLength - 1;
}
//Create the div notification child
var divNotificationChild = document.createElement('div');
divNotificationChild.setAttribute("id", "Notifications" + order);
divNotificationChild.setAttribute("Order", order);
divNotificationChild.setAttribute("Severity", "2");
divNotificationChild.setAttribute("Source", "Server");
//Create the notification table
var tableNotification = document.createElement('table');
var tbodyNotification = document.createElement('tbody');
var trNotification = document.createElement('tr');
/*
Build the image if the type of message
type of:
-information = 1
-warning = 2
-error = 3
*/
var tdImage = document.createElement('td');
tdImage.setAttribute("vAlign", "top");
var img = document.createElement('img');
img.setAttribute("class", "ms-crm-Lookup-Item");
switch (informationType) {
case 1:
img.setAttribute("src", "/_imgs/error/notif_icn_info16.png");
break;
case 2:
img.setAttribute("src", "/_imgs/error/notif_icn_warn16.png");
break;
case 3:
img.setAttribute("src", "/_imgs/error/notif_icn_crit16.png");
break;
default:
img.setAttribute("src", "/_imgs/error/notif_icn_info16.png");
break;
}
tdImage.appendChild(img);
/*
Build the <td> with the title and text message
*/
var tdText = document.createElement('td');
var textSpan = document.createElement('span');
var boldText = document.createElement('b');
textSpan.setAttribute("id", "Notification" + order + "_text");
boldText.setAttribute("color", "#FF0000");
//put the title
boldText.appendChild(document.createTextNode(title + ": "));
//put the text information
//textSpan.appendChild(document.createTextNode(text));
textSpan.innerHTML = text;
tdText.appendChild(boldText);
tdText.appendChild(textSpan);
trNotification.appendChild(tdImage);
trNotification.appendChild(tdText);
tbodyNotification.appendChild(trNotification);
tableNotification.appendChild(tbodyNotification);
divNotificationChild.appendChild(tableNotification);
divNotifications.appendChild(divNotificationChild);
divNotifications.style.display = 'block';
}
//clear the notifications on the form.
function ClearNotifications() {
var divNotifications = document.getElementById('Notifications');
var childNodesLength = divNotifications.childNodes.length;
if (childNodesLength == 0)
return;
var i = 0;
for (i = 0; i < childNodesLength; i++) {
var childDiv = divNotifications.childNodes[i];
divNotifications.removeChild(childDiv);
}
divNotifications.style.display = 'none';
}
O resultado você pode visualizar abaixo:

However, it is important to balance your lower body gains with your upper body gains college-homework-help.org