Search code examples
javascriptdynamics-crm-2011dynamics-crmdynamics-crm-2013

Making a field read-only in MS CRM 2013


I want to use javascript to make a page read-only in MS CRM 2013. I have found a solution like this:

var ToBeReadOnlyControl = Xrm.Page.ui.controls.get("ownerid");
ToBeReadOnlyControl.setDisabled(true);

The idea is to browse all fields and disable them, but I want to just make a field read only and not disable it with a "padlock".

Do you have any idea how I can do this in javascript?


Solution

  • If you need to disable all fields, the record apparently needs to be read-only. The preferred way to achieve this is by using the built-in security options of Dynamics CRM, applying security roles and/or record shares.

    If you cannot achieve your goals in this way, you may want to use a client script that just disables all enabled fields on the form. I would highly recommend to stick to the standard here and use the API methods for this purpose accepting that this is just how the product works.

    The padlocks can only be removed by directly manipulating the HTML DOM, which is unsupported and can potentially break on every product update Microsoft releases. Keep in mind, Microsoft still has some work to do on the GUI side, so this concern is not far fetched.