How to make a field read only RRS feed

  • Question

  • I have a requirement to make a field read only in plugin using c# for crm 2011. Kindly help me in doing the same.
    Tuesday, July 16, 2013 9:16 AM

All replies

  • Hi...

    Its not possible through C# plugin  because read only is the client side script.

    In java script 


    Tuesday, July 16, 2013 9:26 AM
  • I don't think you can make the field readonly from a plugin because read-only is a client side functionality. But you can write javascript for that.

    You can take following steps to make field read only from plugin using Javascript.

    1. Create a new bool type Field (flag); something like 'new_makeReadOnly'.

    2. Set the value of 'new_makeReadOnly' from your plugin.

    3. On form load create a javascript function (as following) to make the field readonly.

    var isReadOnly = Xrm.Page.getAttribute(“new_makeReadOnly”).getValue() ;

    if(isReadOnly  == true)



    // OR

    // Xrm.Page.getControl("new_myField").setDisabled(true);


    • Proposed as answer by jattscorpion Tuesday, July 16, 2013 9:29 AM
    • Edited by jattscorpion Tuesday, July 16, 2013 11:45 AM correction
    Tuesday, July 16, 2013 9:27 AM
  • HI sankar,

    Why do you want to make readonly thorugh plugin? You can use javascript right?

    By using javascript you can make it to readonly when ever you want, means on onload,onchange and onsave.

    I think through plugin it is not possible. Try with javascript.



    Sravan J.

    • Edited by sravan J Tuesday, July 16, 2013 9:33 AM update
    Tuesday, July 16, 2013 9:31 AM
  • Any reason you wanna do this in plugin not using JavaScript?

    You can put a boolean field on form and update that to "Yes" in your plug-in logic.

    In onLoad event of form, check the value of that boolean field, if it is yes, then make your field read-only else not use below JavaScript line:


    • Proposed as answer by myCRMGuy Tuesday, July 16, 2013 9:48 AM
    Tuesday, July 16, 2013 9:31 AM