Saturday, August 16, 2008

Disable CRM Form

All MS CRM Controls have a common Disabled Property.
In order to disable the entire form you need to disable each and every control.


function OnCrmPageLoad()
{
ToggleFormFields(true);
}

function ToggleFormFields( disable )
{
for( var i = 0 ; i < crmForm.all.length ; i++ )
{
if( crmForm.all[ i ].req )
crmForm.all[ i ].Disabled = disable;
}
}

OnCrmPageLoad();

3 comments:

Flavio G Araujo said...

Excelente !!!

nitesh said...

What is the meaning of .req here??

Anonymous said...

Hi Nitesh,

.req is the CRM-internal property for the RequirementLevel of the field. Here it is only used to filter out all elements of crmForm.all which dont have this property, because they are no entity-attributes (form-fields).

e.g. the tabs of the form are also elements of crmForm.all but should not be disabled here, cause this are no fields.

Regards
Thomas