Hello,
If the field is not on the form then
formContext.getControl("fieldschemanamehere") returns null
so in order to satisfy your requirement you can use syntax that is similar to following:
function setFieldDisabled(formContext, fieldName, isDisabled) {
var fieldControl = formContext.getControl(fieldName);
if (!fieldControl) {
return;
}
fieldControl.setDisabled(isDisabled);
}
and here is an example on how to use that function:
setFieldDisabled(formContext, "telephone1", true);
setFieldDisabled(formContext, "emailaddress1", true);
...e.t.c.