Form scripting allows you to create a script to perform a variety of actions within the Microsoft Dynamics CRM Online client application running in Microsoft Internet Explorer on the user's computer, including Microsoft Dynamics CRM Online for Outlook. When data is available in the client, using scripts to perform actions there provides better performance than using methods that require the user to save the record to perform the actions on the Web server.
To do customizations that affect the full Microsoft Dynamics CRM Online organization, you must have the System Administrator or System Customizer security role, or equivalent privileges.
Scripts can perform a wide range of actions, such as:
- Calculate the values in a form.
- Use Web services to retrieve data on or to update external data sources.
- Interact with an HTML page or Web application on the same domain within an IFrame.
- Perform actions on Microsoft Dynamics CRM Online data using Microsoft Dynamics CRM Online Web services.
When you develop scripts that interact with forms, be sure to use only the supported objects, properties, and methods that are documented in the Microsoft Dynamics CRM SDK. This will help to ensure that your form scripting customizations can be upgraded to the next version of Microsoft Dynamics CRM Online.
Associating Scripts with Events
Microsoft Dynamics CRM Online, write a script using JScript. Associate the script with events on the Microsoft Dynamics CRM Online form or fields within the form.
Microsoft Dynamics CRM Online supports the following events on every entity form: OnLoad, OnSave, TabStateChange, and OnReadyStateComplete. The TabStateChange event indicates when the tab is expanded or collapsed.
The OnChange event is available on every field in the form.
This means that you can include logic within a form to run when the form loads, when a user saves the form, or when the value of a field on the form changes. Microsoft Dynamics CRM Online processes the OnChange event first, and then the data in the field is validated again following the execution of the OnChange event code.
Each form or field provides an Events dialog where scripts can be pasted and enabled. After you save and publish the event, the scripts become part of the metadata for the entity. This means that they can be exported and imported with other customizations. More information: Add event handlers for field events, Add event handlers for form events