User Review
( votes)Introduction
Normally, using Xrm.Utility.getEntityMainFormDescriptor Client API, we get the details of default main form of specified entity in the form of sections and attributes list. If we want to get the list of all the entity attributes or sections that is visible on an entity form, then we can use this Client API. In this blog, we have explained the use of this Client API through the below example.
In our recent project, we had a requirement to design an HTML form where we show entity form sections (that is visible on entity form) of specified entity. For this, we have to retrieve sections of the entity main form of the given entity. To achieve this requirement, we used Xrm.Utility.getEntityMainFormDescriptor Client API of Dynamics 365 CRM.
Please find below the code where we have shown how to use Xrm.Utility.getEntityMainFormDescriptor Client API.
Here, we have passed the account entity main form id and a logical name.
var formId = '8448b78f-8f42-454e-8e2a-f8196b0419af'; //form id
var entityName = "account"; //entity logical name
// Get the main form descriptor
Xrm.Utility.getEntityMainFormDescriptor(entityName, formId).then(function
(response) {
var entityFormSections = response.Sections;
}, function(error) {
console.log(error.message);
});
Given below is the screenshot of the debugger where we get sections of the given entity form of the entity.
Also, please find below the screenshot of the debugger where we get the ‘Visible’ property in each section. This helps to filter the visible sections of entity form.
Conclusion
In this way, with the help of Xrm.Utility.getEntityMainFormDescriptor Client API, we can easily get the entity form information.