This task requires the System Administrator or System Customizer security role A defined set of privileges. The security role assigned to a user determines which tasks the user can perform and which parts of the user interface the user can view. All users must be assigned at least one security role in order to access the system. or equivalent permissions. Customization tasks can be performed only while you are online. More information: Customization Permissions
Always set dependencies on any form fields referenced in your scripts. Removing a field that a script references causes an error when the script runs. Set such a field as dependant helps to prevent the accidental removal of a field that a script references. More information: Form Scripting
You should have a thorough knowledge of JScript programming syntax and an understanding of the Xrm.Page object model before adding scripts, and should test your scripts before you publish customizations. Malformed scripts can prevent the form from working correctly.
In the Navigation Pane, click Settings.
Under Customization, click Customizations.
In the Customization area, click Customize the System.
Under Components, expand Entities, and then expand the entity you want.
Click Forms. In the list, click a form to edit it if it has a Form Type of Main.
On the Home tab, in the Select group, click Body.
In the main pane, double-click the field to which you would like to add an event.
In the Field Properties dialog box, on the Events tab, select one of the available events, and then click Add.
In the Handler Properties dialog box, supply the requested information. Select the Enabled check box to make the function available to be called by a field event.
Click OK to close the Handler Properties dialog box.
Click OK to close the Field Properties dialog box.
Test your script in the three modes a form can be used: create, update, and read-only:
On the Home tab, click Preview, and then select Create Form, Update Form, or Read-Only Form.
For the create and update modes, enter data in the field and move focus off the field by selecting a different field to verify that the script executes.
To close the Preview form, on the File menu, click Close.
Click Save and Close to close the form.
When your customizations are complete, publish them:
To publish customizations for only the component that you are currently editing, on the Home tab, in the Save group, click Publish.
To publish customizations for all unpublished components at one time, click Publish All Customizations.