In the example below, I will explain how to make a form read-only based on a field value:
if (Xrm.Page.ui.getFormType() == 2 && Xrm.Page.getAttribute("new_accountstatus").getValue() == 100000001)
var controlType = control.getControlType();
return controlType != "iframe" && controlType != "webresource" && controlType != "subgrid";
Xrm.Page.ui.controls.forEach(function (control, index)
- Navigate to the Customizations screen (Settings > Customizations > Customize the System).
- Select the Web Resources link, and click on New. In the new Web Resource window, enter a Name (with no spaces) and a Display Name. Select “Script (Jscript)” for the Type, and click on Text Editor.
- Save and Close the Web Resource window.
- With the Account Form open, click on Form Properties
- In the Form Properties window, click on Add in the Form Libraries section. A Look Up window will open. Select your new library, and click on OK.
- In the Event Handler section of the Form Properties window, set the Control = Form, and Event = OnLoad, then click on the Add button. In the Handler Properties window select your new Library, and type setupForm in the Function field. Make sure the Enabled box is checked, and click on OK.
- After adding the library and event handler, click on OK to save and close the Form Properties window.
- Back on the Account Form, click on Save, and then Publish.
- When an existing Account record is opened, if the Account Status field is blank or set to anything other than “Customer”, the fields can be modified:
- But if the Account Status is set to “Customer”, the fields become read-only:
NOTE: even though the fields on the Account form are read-only, iFrames and sub grids embedded in the record, such as the Contacts sub grid, can still be modified:
There are a number of other ways the system can be configured to fit the needs of your business. RSM is a partner with the Gold Customer Relationship Management (CRM) Competency in the Microsoft Partner Network and can implement Microsoft Dynamics™ CRM solutions from the basic "out of the box" model to a complex architecture. This competency means RSM demonstrates an ability to meet Microsoft customers’ evolving needs in today’s dynamic business environment and has completed a rigorous set of tests to prove their level of technology expertise.
If you are interested in learning more about how RSM can help your organization, our professionals can be reached via email at [email protected] or by phone at 800.274.3987.
By: Melissa Otto, RSM –