Customization

Form scripting customizations

Part 10 of "11 things to know about customization"

There are many advantages to implementing customizations to occur on a user's computer. These customizations are faster because they do not require a round trip to the server before they are applied. Form scripting is the way to achieve this in Microsoft Dynamics CRM Online.

On This Page

Events

Adding scripts

Form object model

Microsoft Dynamics CRM Online Web services

Events

Microsoft Dynamics CRM Online supports two events on every entity form: OnLoad and OnSave.

The OnChange event is available on every field in the form.

This means that you can include logic within the form when it loads, when a user saves, or when the value of a field changes.

Adding scripts

You paste your scripts into the definition of the entity forms. Scripts then become part of the entity metadata, and can be exported and imported to another system alongside all the other customizations.

Caution

You should have a thorough knowledge of JScript programming syntax and an understanding of DHTML before you add scripts, and should test your scripts before you publish customizations. Malformed scripts can prevent the form from working correctly.

  • Add or edit an event-based script to a form
  • Add or edit an event-based script to a field

    Note

When you use an event-based script or custom code that refers to specific fields, you should set these fields as dependent fields so that they cannot be deleted from forms. The Event Detail Properties dialog box provides a Dependencies tab where you can add any fields referenced in your script for the event.

The scripting language is JScript, which is functionally equivalent to JavaScript and is well known by many Web developers. For each event, a developer can interact with an object model in the form. This object model is documented in the Microsoft Dynamics CRM Software Development Kit. See Client-side Scripting (Microsoft Dynamics CRM SDK), which describes how a developer can access different properties and methods on the forms.

Form object model

Microsoft Dynamics CRM Online supports using the objects and methods that are provided by Microsoft Dynamics CRM Online. But, because Microsoft Dynamics CRM Online uses Internet Explorer to show the pages, developers can do almost anything that they usually do in a Web application. They can call a Web service or work with another application displayed in an IFrame.

The important thing to avoid in form scripting is referencing any of the HTML elements of the Microsoft Dynamics CRM Online pages that are not documented in the Microsoft Dynamics CRM Software Development Kit. The only supported elements in the pages that can be programmatically referenced or manipulated are documented in this guide. You might not be able to upgrade your customizations to a future version of Microsoft Dynamics CRM Online if you reference unsupported elements or functions because they might not exist in the next version. For more information about things to avoid in form scripting and why, see Unsupported scripting in the Microsoft Dynamics CRM Online Team Blog.

Microsoft Dynamics CRM Online Web services

Microsoft Dynamics CRM Online supports calling Microsoft Dynamics CRM Online Web services directly from client-side code, whether that code is associated with a form event or with JScript configured in an ISV.Config button or menu item. These Web service calls work for both the Microsoft Dynamics CRM Online Web application and Microsoft Dynamics CRM Online for Microsoft Office Outlook. While you are offline with Microsoft Dynamics CRM Online for Outlook, the local Web services are used. The Microsoft Dynamics CRM Software Development Kit documents functions developers can use to help craft the XMLHTTP requests used to call these Web services.

Related Links