RSS

CRM2013 – Form Level Notifications

02 Dec

Introduction

In this blog, I will explain how to display Form level Notifications in CRM 2013.

Background

The requirement was, on entering an Account form the Account Number must be greater than 4 digits and Main Phone is a mandatory field or else we will show a notification “Account number should be more than 4 digits” and “Main phone field is mandatory” on the Form level.

Code

We will use the following two methods for our task.

  • setFormNotification(message, level, uniqueId) : To set the notification on Form level.
    1. message : Text of the notification.
    2. level : Message icon – can be “ERROR”, “WARNING” or “INFO”.
    3. uniqueid : Id to be used to clear notification.
  • clearFormNotification() : To remove the Notification from the Form.

Code can be used onChange or onSave event.

//Function To Show Error Notification On Form Level
function FormNotificationError()
{
    //Check If Digit Count of Account Number Is Less Than 4 or not
    if (CountDigit(Xrm.Page.getAttribute("accountnumber").getValue()) <= 4)
    {
        //Set The Form Notification With Error Icon
        Xrm.Page.ui.setFormNotification("Account number should be more than 4 digits", "ERROR", "accountnumber");
    }
    else
    {
        //Clear Notification
        Xrm.Page.ui.clearFormNotification("accountnumber");
    }
}

//Function To Show Warning Notification On Form Level
function FormNotificationWarning()
{
    //Check If The Main Phone Is Not Blank
    if (Xrm.Page.getAttribute("telephone1").getValue() == null)
    {
        //Set The Form Notification With Warning Icon
        Xrm.Page.ui.setFormNotification("Main phone field is mandatory", "WARNING", "telephone1");
    }
    else
    {
        //Clear Notification
        Xrm.Page.ui.clearFormNotification("telephone1");
    }
}

//Function To Get Count Of Digits
function CountDigit(number)
{
    return number.toString().length;
}

Output

Image
The screen shot displays the notification on the Form level for Account Number and Main Phone.

By Abhisek Sriramka
Senior Software Engineer @Team DynamicsCRM.
Mindfire Solutions

Advertisements
 
 

Tags: , , , , , , , , , , , , , , , , ,

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: