How to set form notification in CRM 2013 using JScript – CRM 2013 Feature


There is a new client API  feature introduced in CRM 2013 – Setting Form and Field level notifications through Jscript.

Let’s have a look at how to set the form notification on the Account form.

We will be using the new Xrm.page.ui.setFormNotitication() method to achieve this.

Xrm.Page.ui.setFormNotification(message, level, uniqueId);

Parameters

message | Type: String. The text of the message.

level | Type: String. The level of the message.

The level defines how the message will be displayed.

  • ERROR : Notification will use the system error icon.
  • WARNING : Notification will use the system warning icon.
  • INFO : Notification will use the system info icon.

uniqueId | Type: String. A unique identifier for the message used with clearFormNotification to remove the notification.

Sample Method which calls this method – registered on the OnSave() event of Account form

function AlertOnAccountForm() {
 Xrm.Page.ui.setFormNotification('Sample Error Notification message for Demo ', 'ERROR', '1');
 Xrm.Page.ui.setFormNotification('Sample information Notification message for Demo ', 'INFORMATION', '2');
 Xrm.Page.ui.setFormNotification('Sample Warning Notification message for Demo ', 'WARNING', '3'); }

And the form UI will be like this:

FormNotofication_screen

By default, the notifications would be sorted in the below order of notification type

  1. Information
  2. Error
  3. Warning

In order to clear the notification, Xrm.page.ui.clearFormNotification() method can be used by passing the uniqueid as parameter.

function ClearAccountFormNotification() {
Xrm.Page.ui.clearFormNotification('1');
}


And the notification with id ‘1’ [Error added] will be removed from the form

FormNotofication_screen_clearError

©Dynamics CRM Guru Blog

Advertisements

About Dynamics CRM Guru

We are a group of CRM Consultants and have significant experience in transforming businesses in the right way. We use this platform to share our knowledge which might help many others in the digital transformation journey. We are happy to help you if you are looking for any assistance in CRM implementation projects.

Posted on March 9, 2016, in Code type, JScript, Microsoft CRM 2013, Microsoft CRM 2015, Microsoft Dynamics and tagged , . Bookmark the permalink. Leave a comment.

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

%d bloggers like this: