Xrm.Page Object Model

Xrm.Page Object Model in Dynamics 365

In addition to triggering code to run after specific events occur, Microsoft Dynamics CRM provides an object model of form elements that can be utilized to manipulate data, change form object properties, or analyze the current state of the form or data within the form. This object model is called Xrm.Page and in addition to the event handlers are the primary tool used to develop custom business logic at the client-side.

Tip! Want to learn Dynamics 365 development skills?  Check out Developer Environment and Developer Extending events.

Some benefits of using the Xrm.Page model are:

  1. Change the appearance or manipulate form objects like data controls (text boxes, checkboxes, etc.), tabs, sections, etc.
  2. Identify elements to show/hide.
  3. Specify names of objects from which to retrieve/store data values.
  4. Provide namespaces to properties so the system allows multiple controls per field or multiple forms per entity.

The Xrm.Page model provides a namespace container for following objects:

Xrm.Page object model



Context provides methods to retrieve information specific to an organization, a user, or parameters that were passed to the form in a query string by event handler registered on Form.

The context object is used in forms by using the Xrm.Page.context syntax. There are several functions that are accessible through the context object, such as getUserId. The following code will return the current user’s UserId.



Data provides access to the data on Entity Form. Values can get or set fields on CRM form after data validation or data manipulation.

The following code will return the value of the email address field:


Or,  a shortcut for this code is:


The following code will set the value of the email address field:



UI provides methods to retrieve information about the user interface, collections for several sub components of the form. It provides access to each control present on the form.

The following code will close the current form:


This code will get the value of the associated label of the email address field.


The CRM Xrm.Page Object Model is very broad. Further documentation regarding its capabilities can be found in the Microsoft Dynamics CRM SDK or using the following resources:

Using Javascript with Microsoft Dynamics CRM: http://msdn.microsoft.com/en-us/library/hh771584.aspx

Do More with Dynamics 365

Expand your knowledge of Dynamics 365 through PowerObjects’ educational blogs.  Looking to learn in a more formal setting?  Check out our in-person training courses.

Want to learn development skills?  Check out Developer Environment and Developer Extending events.