RSS

CRM 2013 – Field Level Notification

29 Nov

Introduction

In CRM 2011, there was no Out of Box Functionality to show client side notifications on the Entity. We have used JScripts functions to show alert messages using Web Resources. In CRM 2013, Microsoft has introduced some new methods to show notifications on client side.

Background

The requirement was, while entering data in an Account form, the Account Number must be greater than 4 digits, else we had to show a notification “The account number should be more than 4 digits” on the field level.

Code

We will use following two methods for our task.

  • setNotification(message) : To set the Notification near the field
  • clearNotification() : To remove the Notification from the field

Code can be used onChange or onSave event.

//Function To Set Notification On Field Level
function SetFieldNotification()
{
    //Get The Control
    var field = Xrm.Page.getControl("accountnumber");

    //Get The Count Of Digits In Acccount Number
    var numberOfDigit = CountDigit(field.getAttribute().getValue());

    //Check if digit count of Account Number is less than 4 or not
    if (numberOfDigit <= 4)
    {
        //Set The Notification
        field.setNotification("The account number should be more than 4 digits");
    }
    else
    {
        //Clear The Notification
        field.clearNotification();
    }
}

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

Output

Image The Screen shot displays the notification near Account Number field.

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

Advertisements
 
Leave a comment

Posted by on November 29, 2013 in WebResources

 

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: