Thursday, May 3, 2007

Hiding and Disabling CRM fields with Javascript

I always forget the syntax for hiding and disabling fields in CRM. Below are some common examples:

//hide contract and contract line fields
crmForm.all.contractid_d.style.visibility = 'hidden';
crmForm.all.contractdetailid_d.style.visibility = 'hidden';

//disable lookup fields
var oField = crmForm.all.SOME_FIELD_ID;
oField.Disabled = !oField.Disabled;


//disable radio button field
crmForm.all.new_inboundoutbound.disabled = true;

//disable datetime field
if(crmForm.FormType!=4)
{
//disable data field
var oField = crmForm.all.new_resolutiondate;
oField.Disabled = !oField.Disabled;
}

No comments: