We will learn and understand the getEntityMainFormDescriptor client API in Dynamics 365 CRM. Before we start, make sure to subscribe to CRM Crate.
What is client API reference for model-driven apps?
A. The Client API object model also contains the Xrm.Internal namespace, and use of the objects/methods in this namespace isn’t supported. These objects, and any parts of the HTML Document Object Model (DOM), are subject to change without notice. We recommend that you don’t use these functions or any script that depends on the DOM.
B. Also, while debugging, you may find methods and objects in the Client API object model that aren’t documented. Only documented objects and methods are supported.
C. Most of the client scripting APIs available in this documentation also apply to Dynamics 365 Customer Engagement (on-premises). For a list of client scripting APIs not available for Customer Engagement (on-premises), see Client scripting reference for Dynamics 365 Customer Engagement (on-premises).
Understanding the getEntityMainFormDescriptor client API –
The Xrm.Utility.getEntityMainFormDescriptor client API is used to get the details of default main form of specified entity in the form of sections and attributes / field list.
The getEntityMainFormDescriptor returns the main form descriptor for the specified table.
Syntax for using getEntityMainFormDescriptor –
Xrm.Utility.getEntityMainFormDescriptor(entityName, formId);
Name | Type | Required | Description |
---|---|---|---|
entityName | String | Yes | The logical name of the table. |
formId | String | No | The form ID of the table. |
The above promise returns the below given parameters –
Parameter Name | Type | Description |
---|---|---|
Attributes | Array of strings | List of all the columns on the main form. |
EntityLogicalName | String | The logical name of the specified table. |
Id | string | The form ID of the specified table. |
Label | String | The label of the specified table. |
Name | String | The display name of the specified table. |
Sections | String | The sections name of the specified table. |
ShowLabel | Boolean | Indicates whether to show the label of the specified table or not. |
Visible | Boolean | Indicates whether the form is visible or not. |
JavaScript Code Snippet for getEntityMainFormDescriptor in Dynamics 365 CRM
We have developed a JavaScript code for retrieving the list of forms sections using getEntityMainFormDescriptor .
A. Below is the code snippet which calls the getEntityMainFormDescriptor client API to retrieve the list of sections in the form.
function CallMethod (executionContext) { //CRM Crate JavaScript Snippet - //Declare Form ID and Entity Schema Name. var formId = "3d77A72F99-B266-4771-B89A-453E0CEDDD3C"; //Pass the Form ID. var entityName = "cc_researchdevelopment"; //Pass the Entity Schema Name. // Utilize the getEntityMainFormDescriptor client API. Xrm.Utility.getEntityMainFormDescriptor(entityName, formId).then(function (response) { var entityFormSections = response.Sections; console.log(entityFormSections); }, function(error) { console.log(error.message); }); }
B. The output returned from the above code snippet is observed in the debugger console as shown below.
Thus we learned to use the Xrm.Utility.getEntityMainFormDescriptor in Dynamics 365 CRM.