When writing form scripts, we will interact with objects from the Xrm.Page namespace to perform the following actions:
- Get/Set attribute values.
- Show/Hide user interface elements.
- Reference multiple controls per attribute.
- Access multiple forms per entity.
- Manipulate form navigation items.
Xrm.Page Object Hierarchy
Context – Provides methods to retrieve information specific to an organization, a user, or parameters that were passed to a form as a query string.
Data – Provides access to the entity data and methods to manage data in the form.
UI – Contains methods to retrieve information about the user interface, in addition to collections for several sub components of the form.
When you register a function for an event handler, CRM lets you pass the execution context object as the first parameter to the function.
This object contains methods that allow you to managed variables you wish to share with other event handlers.
- Page.data.entity.attributes collection provides access to each entity attribute that is available on the form. Only those attributes that correspond to fields added on the form are available.
- controls provides access to each control on the form.
- controls provide access to each control that have more than one control for an attribute available on the form.
- controls provides a collection of controls found in a section.
- Page.ui.navigation.items collection provides access to navigation items that are defined using the navigation area of the form editor.
If multiple forms are associated with an entity, each form can be associated with a security role and if security roles of a user enable users to see more than one form, they can select from a collection of Xrm.Page.ui.formSelector.items. A form definition is available in this case.
- Page.ui.tabs provides access to collection of each of the tabs present on the form.
A tab can be organized by using more than one section. The tab sections collection provides access to these sections.
Hope this overview was helpful to you!