Translate

Sunday 20 April 2014

How to increase the performance of crm form

Hello CRM Lovers,
         
   Many times we see that crm form takes much time to load, this is really hectic. Every one wants smooth processing of crm. So we have to take care of the thing by which crm perform well.

  Slow processing may be due to fallowing reasons, slow internet, less ram and java scripts on crm form. Improper java scripts code is also a bigger reason for slow processing of crm form.

  In this post of mine I am going to describe about best practices for use of java script code.

These are some things you should remember before using java script on crm form.

1. Do not include unnecessary java script web resource library :-

As we know if any web page contains more script to include on page load, page will take more time to load, so the more scripts you add to the form, the more time it will take to download them. After loading first time scripts get cached in browser. But as we usually say first impression is the last impression, so we have to try to not include unnecessary web resource library on crm form.

For a example, don’t include jQuery in your form scripts simply because if you want to use XMLHttpRequests. While jQuery has the $.ajax function that many people are familiar with to perform these requests, it is a developer preference, not a necessity. It is possible and better also to perform these requests using the native XMLHttpRequest object found in all browsers supported by Microsoft Dynamics CRM.

2. Try to avoid loading all scripts in the Onload eventof the crm form :-

If you have code that only supports OnChange events for fields or the OnSave event, make sure to set the script library with the event handler for those events instead of the OnLoad event. This way loading those libraries can be deferred and increase performance when the form loads. We do not recommend using the addOnChange method within the OnLoad event handler simply as a matter of convenience. While this may reduce the number of steps necessary to add your event handlers, it causes the form to load more slowly.

3. Use collapsed tabs to defer loading web resources :-

Here is one intresting thing whenever a web resources or IFRAMES are included in sections inside a collapsed tab, they will not be loaded if the tab is collapsed so the script will also not get loded on page load. They will be loaded when the tab is expanded. When the tab state changes, the TabStateChange event occurs. Any code that is required to support web resources or IFRAMEs within collapsed tabs can use event handlers for the TabStateChange event and reduce code that might otherwise have to occur in the OnLoad event. So we we have to think and decide which code should written on Onload event of the crm form.

4. Try to set default visibility options :-

We have to use default functionality for hiding attributes, We should avoid to use form scripts in the OnLoad event to hide form elements. Instead, set the default visibility options for form elements that might be hidden to not be visible by default when the form loads. Then, use scripts in the OnLoad event to show those form elements you want to display.

Enjoy the great technology Dynamics CRM. Good luck.

Saturday 19 April 2014

How to filter lookup in crm 2013


How filter lookup in CRM 2013.

Hello CRM Lovers,
         
   After release of CRM 2013 we got many new features in CRM. First is that performance increases of crm. There are various changes in java script functions for increasing performance of crm.

   Here is my new post with the new java scripts in crm 2013 for filtering lookup. In CRM 2013 there are many new functions for filtering like prefilter, removePrefilter etc. In this post I am going to describe how to use these functions.These functions will also increase performance of crm form.

Here is all about new lookup controls,s methos and events :- 

1. Method : addCustomFilter()  :-  

This function is new in crm 2013. It works as an additional filter to result displayed in lookup dialog each previous filter added with an AND condition to display result in lookup dialog. 

Note :-  
  • This method is only available for updated entities in crm 2013.
  • This method can only be used in a function in an event handler for the Lookup Control PreSearch Event.
 

         
    addCustomFilter();
     
      Xrm.Page.getControl("attributename").addCustomFilter(filter, entityLogicaName);
      
      Here filter is fetch xml for results and entityLogicalName 
      is name of the entity. 
      Example :-         
             <filter type="and">
               <condition attribute="name" operator="eq" value="Test" />
             </filter>

2. How to add custom view on lookup control :- 

Method : addCustomView():- This method is used to add custom view on  the lookup control.

Note :- This method does not work on "Owner" lookup. 


    addCustomView(); 
   
      Xrm.Page.getControl("attributename").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault);

    Where :-
            viewId :- unique guid of format “{00000000-0000-0000-0000-000000000001}”.
    entityName :- Name of the entity of type "string".
    viewDisplayName :- Name of the view(Your custom name)of type "string".
    fetchXml :- fetch for retrieve data of type "string".
    layoutXml :- layout xml is for showing the records in a format as you want of type "string".
    isDefault :- Do you want this view as default of type "bool".

  

3. How to get default view of CRM lookup control :-


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

    Returns the Id of the default view of the lookup dialog in 
    string.

4. How to set default view of CRM lookup control :-


       
    setDefaultView();
       
      Xrm.Page.getControl("attributename").setDefaultView(viewGuid);

              Where :-
      viewGuid :- Guid of the view.
          Set,s the default view in lookup dialog .


5. How to add or remove lookup control PreSearchEvent :-    

         This is new functionality in CRM 2013. Lookup PreSearchEvent just occurs just before the lookup dialog opens. Like other form and control events crm form editor does not peovide a way to add PresSerachEvent.This event can be used with other lookup methods like addCustomView, addCustomFilter etc.

Note :- These events only available for all custom entities in crm 2013 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. 


    addPreSearch();
    
             Xrm.Page.getControl("attributename").addPreSearch(functionName);
      
      Where :-      
      functionName:- is the name of the function which you want to 
                     call before lookup, launch dialog.
    removePreSearch();

      Xrm.Page.getControl("attributename").removePreSearch(functionName);
       
      Where :-      
      functionName:- is the name of the function which you want to remove.

Enjoy the great technology Dynamics CRM. Good luck.

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.