Translate

Saturday, 12 April 2014

New java script functions in CRM 2013


New java script functions for CRM 2013.

Hello CRM Lovers,
          Here is my new post with the new java scripts for crm 2013. This post is all about how to change display behavior of crm controls at client side.

   We access any control on crm from with these objects Xrm.Page.ui.controls, Xrm.Page.uiSection.controls, or Xrm.Page.data.entityAttribute.controls. The Xrm.Page.getControl may be accessed by Xrm.Page.ui.controls.get
    In this post I am goint to tell you how to use Xrm.Page.getControl method to access a control. Which control depends on the arguments passed to the method.

   Whenever a form displays or loads in crm 2013 a business process flow control in the header, additional controls will be added for each attribute that is displayed in the business process flow. These controls have a unique name like the following: header_process_<attributename>.
Controls displayed in the form header are accessible and have a unique name like the following: header_<attributename>.

1. How to get type of a CRM attribute  :-


         
    getControlType();
     
      var attrType = Xrm.Page.getControl("attributename").getControlType();
    
    Return type will be string. returned values may be standard,optionset,lookup,
    subgrid,notes,webresource,iframe,lookup.

2. How to get name of crm attribute :-



    getName(); 
   
      var attrName = Xrm.Page.getControl("attributename").getName();

            Returns the name assigned to the attribute.   

3. How to get parent of crm attribute :-


    
    getParent();
       
      var attrParent = Xrm.Page.getControl("attributename").getParent();

    Returns the object of the parent control or section in which 
    current control resides.

4. How to get and change label of CRM attribute :-


       
    getLabel();       

         var attrLabel = Xrm.Page.getControl("attributename").getLabel();

    setLabel();
         var attrLabel = Xrm.Page.getControl("attributename").setLabel("labelname");

5. How to display or remove notification about the CRM attribute :-    

         setNotification method displays a message nearby the attribute to indicate that data entered in the attribute is not valid . Whenever this method is used on Microsoft Dynamics CRM for tablets a red "X" icon appears next to the attribute. On tapping on the icon message will display. 

Note :- setNotification and clearNotification methods only available for all custom entities and these system entities :- Account,  Appointment, Campaign, Campaign Activity,Campaign Response,Case,Competitor,Contact,  Contract,Contract Line,Email,Fax,Invoice,Lead,Letter,Marketing List,Opportunity,Opportunity,  Product,Order,Phone Call,Price List Item,Product,Quick Campaign,Quote,Recurring Appointment, Sales Literature,Team,Task,User. 


    setNotification();
    
             Xrm.Page.getControl("attributename").setNotification("message","uniqueid");
      //type of uniqueid should be string, it is just used to 
        remove notification. Returns type of bool.
   
    clearNotification();

      Xrm.Page.getControl("attributename").setNotification("uniqueid");     
      //Returns type of bool.

Enjoy the great technology Dynamics CRM. Good luck.

Post a Comment