In CRM 2011, one way to show custom messages is using Jscript ‘alert’ function.

In one of our requirement we have to display a custom message on CRM form banner like OOB notification.

Notification
Notification

We can achieve this using Jscript, but it’s an unsupported way and there are no guarantees that this code won’t change in the future.

I am providing 2 scripts which is compatible Pre and Post UR 12.

Post UR 12

// Level – 1 (Critical), Level – 2 (Info), Level – 3 (Warning),

function addNotification(message, level) {

try {

var notificationsList = Sys.Application.findComponent(‘crmNotifications’);

if (notificationsList) {

notificationsList.AddNotification(‘noteId1’, level, ‘namespace’, message);

}

} catch (e) {

}

}

Pre UR 12

// Level – 1 (Critical), Level – 2 (Info), Level – 3 (Warning),

function addNotification(message, level) {

try {

var notificationsArea = document.getElementById(‘crmNotifications’);

if (notificationsArea) {

if (level == 1) { //critical

notificationsArea.AddNotification(‘mep1’, 1, ‘source’, message);

}

if (level == 2) { //Info

notificationsArea.AddNotification(‘mep3’, 3, ‘source’, message);

}

if (level == 3) { //Warning

notificationsArea.AddNotification(‘mep2’, 2, ‘source’, message);

}

if (message == “”) { // Clear the notifications

notificationsArea.SetNotifications(null, null);

}

}

} catch (e) {

}

}

How do I use the method

  • To show custom message as Information, pass message and Level =2

              addNotification(“This is sample message.”, 2);

Note – CRM 2013, has a new feature to display  Notifications which is a supported way.

🙂

Leave a Reply

Visitors

2,237,274 hits

Top Posts

Discover more from Rajeev Pentyala – Technical Blog on Power Platform, Azure and AI

Subscribe now to keep reading and get access to the full archive.

Continue reading