RSS

Tag Archives: Notification

CRM2013 – Form Level Notifications

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

 
 

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

CRM 2013 – Field Level Notification

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

 
Leave a comment

Posted by on November 29, 2013 in WebResources

 

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

 
%d bloggers like this: