Hi,
Here is the Jscript code to disable the CRM Form (i.e., Fields on the form)
function doesControlHaveAttribute(control){
var controlType = control.getControlType();
return controlType != “iframe” && controlType != “webresource” && controlType != “subgrid”;
}
function disableFormFields(truefalse){
Xrm.Page.ui.controls.forEach(function(control, index) {
if (doesControlHaveAttribute(control)){
control.setDisabled(truefalse);
}
});
}
How do I call this?
- To disable Form – disableFormFields(true)
- To Enable Form – disableFormFields(false)
Hope it Helps 🙂

![[Step by Step] Beginner : Create a PCF control and add it to a custom page](https://rajeevpentyala.com/wp-content/uploads/2024/12/image-49.png)

Leave a comment