some commonly used JavaScript functions and methods in Dynamics 365 (Microsoft CRM) using the updated formContext object:
- Get the form context:
javascriptvar formContext = executionContext.getFormContext();
- Get the attribute object:
javascriptvar attribute = formContext.getAttribute("fieldName");
- Get the attribute value:
javascriptvar value = attribute.getValue();
- Set the attribute value:
javascriptattribute.setValue(newValue);
- Enable or disable the attribute:
javascriptattribute.setDisabled(true); // Disable
attribute.setDisabled(false); // Enable
- Make the attribute required or not required:
javascriptattribute.setRequiredLevel("required"); // Required
attribute.setRequiredLevel("none"); // Not Required
- Show or hide a section:
javascriptformContext.getControl("sectionName").setVisible(true); // Show
formContext.getControl("sectionName").setVisible(false); // Hide
- Show or hide a tab:
javascriptformContext.ui.tabs.get("tabName").setVisible(true); // Show
formContext.ui.tabs.get("tabName").setVisible(false); // Hide
- Show or hide a field on the form:
javascriptformContext.getControl("fieldName").setVisible(true); // Show
formContext.getControl("fieldName").setVisible(false); // Hide
- Refresh the form:
javascriptformContext.data.refresh();
Comments
Post a Comment