This object allows us to work with the different controls that are available in Dynamics 365 CE. The following are the commonly used standard control type methods that are available under this object:
addNotification |
We can use this method to display a notification for the field or to display an error message to the user based on the value. We can also suggest an action under the notification:
formContext.getControl(arg).addNotification(notification); |
clearNotification |
This method clears notifications that have been displayed using the addNotification method:
formContext.getControl(arg).clearNotification(uniqueId); |
getAttribute |
We can use this method to get an attribute associated with a control:
formContext.getControl("controlname").getAttribute(); |
getControlType |
If we want to know the type of a control, we can use this method:
getControl("controlname").getControlType();It will return a control type such as lookup, iframe, or optionset. |
getDisabled | We can use this method to find out whether a control is disabled:
formContext.getControl("controlname").getDisabled(); |
setDisabled |
We can use this method to disable a control:
formContext.getControl("controlname").setDisabled(bool); |
getVisible |
We can use this method to find out whether a particular control is visible or not:
formContext.getControl("controlname").getVisible(); |
setVisible |
This method can be used to set the visibility of a control:
formContext.getControl("controlname").setVisible(bool); |
setFocus |
We can use this method to set the focus of a control:
formContext.getControl("controlname").setFocus(); |
All of the preceding methods are useful for working with controls such as hiding and showing controls based on the different conditions and to show notifications to users.