Translate

Monday, 31 March 2014

CRM 2013 basic java scripts

.

Basic Java Script for CRM 2011 and CRM 2013?

Hello CRM Lovers,
          Here is my new post with the basic java scripts for crm 2011 and as well as for crm 2013.


1. How to get and set CRM form attribute value :- 

Note :- Controls that are not bound to an attribute (subgrid, web resource, and IFRAME) do not have this method. An error will be thrown if you attempt to use this method on one of these controls.


        
     //Get Object of attribute :- 
      var attr  =  Xrm.Page.getAttribute("attributename");

    //Get attribute value :- 
      var attr  =  Xrm.Page.getAttribute("attributename").getValue();

    //Set attribute value :-  
      var attr  =  Xrm.Page.getAttribute("attributename").setValue("Value of attrubute type");

 

2. How to set visibility of crm attribute :-



    //Set Visible True :-   
      Xrm.Page.ui.controls.get("attributename").setVisible(true);

    //Set Visible False :-   
      Xrm.Page.ui.controls.get("attributename").setVisible(false);

3. How to enable disable crm attribute :-


    //Returns whether the control is disabled :-
      Xrm.Page.getControl("attributename").getDisabled();

        //Set Read Only :-
      Xrm.Page.getControl("attributename").setDisabled(true);

    //Set Enable True :-
      Xrm.Page.getControl("
attributename").setDisabled(
false);

4. How to set focus CRM attribute :-



        //Set Focus True :-
      Xrm.Page.getControl("attributename").setFocus(true);

    //Set Focus False :-
      Xrm.Page.getControl("
attributename").setFocus(
false);

5. How to show hide CRM form tab :-


    
    //Show CRM Tab :-
             Xrm.Page.ui.tabs.get("tabname").setVisible(true);

    //Show CRM Tab :-
            Xrm.Page.ui.tabs.get("tabname").setVisible(false);