locked
How to disable all the controls on the MS CRM 2015 form? RRS feed

  • Question

  • Hi All,

    Can anyone please help me with an easy method to disable the whole form (ribbon, fields, grids etc.) of an entity?

    I have written some script to disable all the fields (only) on the CRM form but how to disable the whole form at one shot so that if there are any changes in future I need not worry about editing my code again.

    Thanks,

    Sri

    Thursday, June 18, 2015 8:20 AM

Answers

  • Hi,

    I assume you can write a javascript on on load of form and check if your condition is valid. Then you can try with the following code snippet:

    Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {    
        var control = Xrm.Page.getControl(attribute.getName());
        if (control) {
            control.setDisabled(true)
        }
    });

    Thursday, June 18, 2015 11:51 AM

All replies

  • Hello,

    Why would you do that when you can deactivate a record? This disabled all action (ribbon fields, grid) on your record.

    Kind Regards

    Thursday, June 18, 2015 8:44 AM
  • Hi Jochen,

    I cannot make it as inactive as per my requirement goes. There are different flows we follow for our business rules and this form should be disabled in one of the flow only. In all the other flows, we should be able to edit the form and its details.

    Thanks,

    Sri. 

    Thursday, June 18, 2015 8:50 AM
  • Hi,

    I assume you can write a javascript on on load of form and check if your condition is valid. Then you can try with the following code snippet:

    Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {    
        var control = Xrm.Page.getControl(attribute.getName());
        if (control) {
            control.setDisabled(true)
        }
    });

    Thursday, June 18, 2015 11:51 AM
  • Hi Prathibha,

    I used the same but it will disable only the fields existing in the form but not the ribbon, subgrids and other controls in the form. I want to disable the whole form to make is just read only.

    Thanks,

    Sri

    Friday, June 19, 2015 7:27 AM