Tuesday 20 November 2012

Check box Onclick Event in crm 2011


Senario:

we are using the checkboxes in crm 2011.
doing some customizations based on the checkboxes.
but the problem is :
After clicking on the checkbox, you need to click outside the box then only function will execute.

for overcome this problem:

just we need to give the one extra function in onload event.

ex ;
my check box field is : new_stockdelivered

then the function in onload event is :


function onload()
{
crmForm.all.new_stockdelivered.onclick = function()
{
    crmForm.all.new_stockdelivered.FireOnChange();
}
}

for suppose :
i have two fields :
new_stockdelivered and new_stockdelivereddate.
if you check on stock delivered then only date will be enable.

first give the onchange function :


function stockdate()
{
var myAttribute = "new_stockdelivered";
var myControl = Xrm.Page.ui.controls.get(myAttribute);
var detailamt= myControl.getAttribute().getValue();
if(detailamt==true)
{
Xrm.Page.getControl("new_stockdelivereddate").setDisabled(false);
}
else
{
Xrm.Page.getControl("new_stockdelivereddate").setDisabled(true);
}
}

it is in onchange event and onload event.

and extra in onload event :


function onload()
{
crmForm.all.new_stockdelivered.onclick = function()
{
    crmForm.all.new_stockdelivered.FireOnChange();
}
}

it will give immediate effect after click on the checkbox




No comments:

Post a Comment