Xrm.Page is deprecated. How do I use formContext in Dynamics 365

Using Dynamics 365 formContext instead of Xrm.Page

Microsoft Dynamics CRM offers an object model of form elements that can be applied to manipulate data, change form object properties, or to analyze the contemporary state of the form or data in the form. This object model is called formcontext. In this blog post, we will learn why using formContext is better than using Xrm.Page:

Few benefits of using the formcontext model are:

  1. It is used to execute script on event trigger like form onLoad event
  2. It contains control form objects like data controls (text boxes, checkboxes, and so on.), tabs, sections, and so on.
  3. It can be used to discover elements to show/hide.
  4. It gives you the functionality to specify names of elements from which to retrieve/store data values.
  5. It provides namespaces to properties, so it provides access to a collection of fields and forms per entity.

The formcontext container provides properties and methods to work with the data on a form.

formcontext.data is the object that contains properties and methods to help us manipulate items in the form.

Attributes is the collection of non-entity data at the form. Items in this collection are of the same kind as that of the attributes collection. However, they are not attributing to the form entity.

Entities provide properties and methods to retrieve information related to the entity record on the page, the preserve method, and an amassment of all the attributes included in the form. Attribute data is constrained to attributes represented by fields on the form.

Processes offers events, methods, and objects to interact with the business process flow data on a form.

In order to open a new form after you have saved the entity, here is the syntax:

The formcontext container provides properties and methods to work with the UI on a form.

UI provides methods to retrieve information about the user interface and accumulations for several sub components of the form. It provides each Control that is present on the form.

A control represents an HTML element present on the form. Some controls are bound to an attribute, while others can also represent unbound controls inclusive of an IFRAME, Web resource, or a sub grid that has been added to the form.

The formcontext.ui.formSelector allows you to work with form items where a form item is accessible to a specific user only because user is associated with the particular security role. In most cases, there is usually a single form but in case of multiple forms, methods for a form item can be used to change the form the user is viewing. Use the formSelector.items collection to return information about all the forms available for the user. formSelector is not available for Microsoft Dynamics 365 for tablets.

Every item represents one of the to-be-had navigation options available inside the navigation bar for entities that have been up to date to the new user experience or on the left facet of the form for entities that have not been updated yet.

It presents methods to interact with the business process flow control on a form.

It presents methods for gaining entry to all the quick view controls and its constituent controls at the Customer Engagement forms when using the brand-new form rendering engine (also called “turbo forms”). A quick view control is a quick view form added to a main form for Customer Engagement that allows you to view information about a related entity record in the main form. Information in constituent controls in a quick view control can’t be edited.

The quickForms collection presents access to all the quick view controls on a form and has all the standard methods of the collections.

A tab is a group of sections on a page. It carries properties and methods to manipulate tabs as well as get rights of entry to sections in the tab through the sections collection.

Tab reflows the UI of the business process control:

So, all in all we can say that the CRM formContext Object Model is very broad, offers great functionality and has useful features.

If you have any questions or queries, leave a comment below. You can also connect with our BOLDEnthusiasts by clicking here.