In CRM2013,notifications can be displayed on form level and/or on field level. This blog will explain How to use notification next to specific control on the entity form.
We can use the following 2 methods to display and clear the notification next to field/control on the form
- setNotification- Xrm.Page.getControl(controlname).setNotification(message) :
2. clearNotification- Xrm.Page.getControl(controlname).clearNotification() :
Remove a message already displayed for a control. We have to remove the notification to save the form.
Here is the JavaScript code I wrote to display the notification if the “No of Employees” entered on account form is less than 5.
function fieldNotification()
{
//get the control
cont = Xrm.Page.getControl("numberofemployees");
//check if the value is greater than 5
if (cont.getAttribute().getValue()<=5)
{
//set the notification
cont.setNotification("The number of employees should be more than 5");
}
else
{
//clear the notification
cont.clearNotification();
}
}
The above screen shot displays the notification next to “No of employees” control.
Reading your blogs - very helpful even for beginners like me. Thank you Amreek.
ReplyDeleteCouple of questions:
1. How can we add similar logic for multiple fields /controls on the same form.
2. Where do we keep the above code /function - high level steps will be helpful
Thank you again,