Set the CRM Form as Read Only(Disabled) in MS CRM 2011/2013/2015


Sometimes we get requirement to disable each and every field on the CRM form based on a condition.

We can achieve that functionality by writing simple JavaScript.

function setFormAsReadOnly() {

    //Write you conditions here.

function doesControlHaveAttribute(control) {

    var controlType = control.getControlType();
    return controlType != “iframe” && controlType != “webresource” && controlType != “subgrid”;

function disableFormFields(onOff) {

    Xrm.Page.ui.controls.forEach(function (control, index) {
        if (doesControlHaveAttribute(control)) {
Hope this helps.

Happy CRM’ing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s