locked
CRM - JavaScript question RRS feed

  • Question

  • Hello,

    I have the below scenario;

    I have a picklist (schema - cvs_companyorsite) and when I create a record in the account entity I want this to have write access, however when loading records (onload) in the accounts entity I want this field to be disabled. I have the below jscript is setup and configured through the event handlers, which works when loading records (onload), but when I create new records the field is disabled. Can anyone provide me with the code to enable the field to be updated when a form is created, and when the form is being loaded?

    function SetEnabledState()


     var AddressType = Xrm.Page.ui.controls.get("cvs_companyorsite"); 
     AddressType.setDisabled(true);

    }

    Many Thanks


    Sam


    Saturday, August 3, 2013 4:45 PM

Answers

  • Hi,
    to keep enabled the field when a new record is created, you need to check the form type, see this example:

    function SetEnabledState()
    {
       if (Xrm.Page.ui.getFormType() != 1)
       {
          var AddressType = Xrm.Page.ui.controls.get("cvs_companyorsite"); 
          AddressType.setDisabled(true);
       }
    }


    My blog: www.crmanswers.net

    • Proposed as answer by Guido PreiteMVP Saturday, August 3, 2013 7:03 PM
    • Marked as answer by samrr1875 Wednesday, August 7, 2013 7:38 AM
    Saturday, August 3, 2013 7:03 PM