Show/Hide, Enable/Disable, and Set Required
fields.CompanyName.setVisible(true); // Show field
fields.CompanyName.setVisible(false); // Hide field
fields.CompanyName.setDisabled(true); // Disable field
fields.CompanyName.setRequired(true); // Make field required
// Chain multiple actions for efficiency
fields.CompanyName.setVisible(true).setDisabled(false).setRequired(true);
Managing Tabs and Sections
Show/Hide Tabs
tabs.General.setVisible(true); // Show the tab
tabs.General.setVisible(false); // Hide the tab
Show/Hide Sections
tabs.General.Section.Section1.setVisible(true); // Show the section
tabs.General.Section.Section1.setVisible(false); // Hide the section
Bulk Operations on Fields
Apply Changes to Multiple Fields
var companyFields = [fields.CompanyName, fields.Street1, fields.City, fields.Country];//You can set all these fields to visible and enabled with just a few lines of code:XrmEx.Fields.setVisible(companyFields, true); // Show all fieldsXrmEx.Fields.setDisabled(companyFields, false); // Enable all fieldsSummary of Key Points
- Fields: Use .setVisible(), .setDisabled(), .setRequired() for granular control.
- Tabs/Sections: Manage visibility with .setVisible().
- Bulk Operations: Use XrmEx.Fields for efficient handling of multiple field
Conclusion
With xrm-ex
, controlling fields, tabs, and sections is concise, readable, and maintainable. The library's intuitive API minimizes repetitive code, making it ideal for creating dynamic, user-focused forms in Dynamics 365.