New Notifications in CRM 2013

The ability to display form and field notifications in Dynamics CRM has been a popular request from clients since the ancient CRM 4.0 days. It is possible to achieve this in Dynamics CRM 2011, however it requires using unsupported methods with JavaScript and form customizations.

clip_image001

After browsing through the Dynamics CRM 2013 SDK (pre-release documentation), I stumbled across a few new JavaScript functions in the Xrm.Page library. These new functions allow you to display and clear notifications at the form and field levels.

Firstly, let’s take a look at the form-level notification functions under the Xrm.Page.ui namespace. The setFormNotification function takes in three parameters: the message that you want to display, the level of the notification – ERROR, WARNING, INFO (this is the default value), and a uniqueId which is referenced when calling the clearNotification function.

Form-Level Notification Example

Let’s assume that we have an entity called “Event” and we want to display a notification on the form to indicate how much seating space is left for the event. Our business rule is:

1. If between 30% and 60% of seats are filled, display an information message stating “Minimum Capacity Reached”

2. If between 60% and 90% of seats are filled, display a warning message stating “Boy this Event is Popular!”

3. If greater than 90% of seats are filled, display an error message stating “Nearing Maximum Capacity”

Xrm.Page.ui.setFormNotification("Minimum Capacity Reached", "INFO", "capacityFormNotification");

clip_image003

Xrm.Page.ui.setFormNotification("Boy this Event is popular!", "WARNING", "capacityFormNotification");

clip_image005

Xrm.Page.ui.setFormNotification("Nearing Maximum Capacity", "ERROR", "capacityFormNotification");

clip_image007

If we wanted to clear the notification, we can simply call the clearFormNotification function and pass in our unique id. For example:

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

The functions for field-level notification exist under the Xrm.Page.ui.control namespace and are called setNotification and clearNotification. The setNotification function takes in one message parameter while the clearNotification takes in no parameters. CRM will know which notification to clear based on the attribute that the notification is attached to.

Field-Level Notification Example

Xrm.Page.getControl("ros_date").setNotification("Woah! That’s a bit late!");

clip_image008

To clear this notification, we can simple call Xrm.Page.getControl("ros_date").clearNotification();

Finally, this wouldn’t be a good post if I didn’t test the limits of the form-level notifications. I tried setting 100 unique notifications on the Event form but only the first four are displayed. The form threw the following error:

clip_image010

I can see this being a well-utilised feature in many CRM implementations. Take a look at this blog on Colour Indicators to see how this requirement can be met in Dynamics CRM 2011. Please note that this is done using unsupported methods.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s