Tuesday, June 5, 2012

Attach OnClick Event to MSCRM 2011

        In CRM when we select a check box or Radio Button and when we write some code on that that even will only fire when we press tab or when we click outside of that checkbox. This is because only onchange event is available for CRM fields no onclick event is there.

But we can programmatically create a onclick event in CRM for fields,

Just add this JavaScript code to onload of form

function onLoad()
   {       crmForm.all.schema_name.onclick = function ()
              {             
                   //here your code for action to be done
               }    }


Note: Many such events are available like onfocuschange, ondragged, etc.


These events can be found when user debugg the java script using the IE developer tools by pressing f12. and put "crmForm.all.schema_name" in watch window.


Click on below link to find how to debug javascript using IE developer tools.


Happy programming.!! :)