In this webinar, our experts showcase a variety of demo use cases of how different components of the...
Before CRM 2013, if you wanted to alert a user on a form within the browser, the only method available was the standard JavaScript alert. This method would open an alert window over the record the user is viewing, which then must be acknowledged in order for the user to continue.
The code,
alert("This is a standard alert")
produces the pop up window as illustrated below.
With CRM 2013, Microsoft introduced an additional alert method that is specific to CRM, Xrm.Page.ui.setFormNotification. This newer method allows you to specify three different types of alerts: error, information, and warning. Furthermore, instead of popping a window open over the current window, setFormNotification embeds the notification in the CRM page itself. These codes:
Xrm.Page.ui.setFormNotification("This is an INFORMATION notification.", "INFORMATION") Xrm.Page.ui.setFormNotification("This is a WARNING notification. ", "WARNING") Xrm.Page.ui.setFormNotification("This is an ERROR notification. ", "EROR")
produce the notifications in the screenshot below that are visible just under the Account record title.
The code
Xrm.Page.ui.clearFormNotification()
can be used to clear these notifications.
Additionally, you can call out specific fields with the setNotification method. The code
Xrm.Page.getControl("fax").setNotification("This is a notification about the Fax field")
produces the notification attached to the fax field on the Account record shown below.
With these different methods, you can now carefully choose how overt or subtle you would like to be in calling out important information on a record to users.
Want to stay up to date with our blog? Subscribe today!
Happy CRM'ing!
Good roundup but small correction. The 'information' level form notification should be INFO rather than INFORMATION. This produces a blue 'i ' icon rather than the icon-free notification shown
Hello, Great post, i recommend uses "Xrm.Utility.alertDialog()" instead of "alert()"
Any idea how to add a conditional layer to this, so the alert would only display if a certain field on the contact form is set to Yes. I'm fine with the old js alert in the pop-up box, but just wondering if anyone can offer any help with how this script would look. Thanks!
How to clear the notification if set on a specific field using the getControl method?
I have multiple fields that I need to setnotification and i am using below code
HandleCaseTimestamps = function (context) {
var saveEvent = context.getEventArgs();
var timeStampFields = ["ava_workaroundacceptedtime", "ava_workaroundrejectedtime", "ava_solutionavailabletime",
"ava_solutionacceptedtime", "ava_solutionrejectedtime", "ava_emergencycallout", "ava_emergencyrestoredtime",
"ava_systemoutagestarted", "ava_systemoutageended", "ava_1stoutagenotification"];
var today = new Date();
if (timeStampFields != null) {
for (var i = 0; i today) {
//alert("Please enter a date that is not in future");
Xrm.Page.getControl(timeStampFields[i]).setNotification("Please enter a date that is not in future")//I am not sure if this way i can set for all fields.
saveEvent.preventDefault();
}
}
}
}
};
I face issues here.
Suppose I 4 fields in my form and a user enters future date. Through notification I am showing user the message above. Once I set the date to current date or before future date, the focus and error symbol still stays in the same field rather it should go the next field where he has entered another future date clearing the previous one.
What should I do if Xrm.Page.ui.clearFormNotification(); doesn't clean the notifications?