Edit

Controls (Client API reference)

In model-driven apps, a control represents an HTML element on the form. Some controls are bound to a specific column, while others represent unbound controls such as an IFRAME, web resource, or subgrid added to the form.

The control object provides methods to change the presentation or behavior of a control and identify the corresponding column. Access controls by using one of the following collections:

  • formContext.ui.controls
  • formContext.ui Section.controls
  • formContext.data.entity Attribute.controls

The formContext.getControl method is a shortcut method to access formContext.ui.controls.get.

Note

When you perform actions on controls that are tied to a column, consider that the control might appear on the page more than once. Generally, you should perform the same actions for each control for the column. You can loop through the column controls collection and perform the actions on each control.

Controls are categorized by type. Use the getControlType method to determine the type of a control. Certain control methods are available only for specific types of controls.

This article provides information about the methods available for each control type.

Standard control type

These methods are available for a Standard control.

Method Description
addNotification Displays an error or recommendation notification with optional actions.
clearNotification Removes a notification from the control.
getAttribute Returns the column that the control is bound to.
getControlType Returns the type of the control.
getDisabled Returns whether the control is disabled.
getLabel Returns the control's label.
getName Returns the control's name.
getOutputs Returns a dictionary of the control's output properties.
getParent Returns the section that contains the control.
getVisible Returns whether the control is visible.
setDisabled Enables or disables the control.
setFocus Moves focus to the control.
setLabel Changes the control's label.
setNotification Displays an error message to indicate that data isn't valid.
setVisible Shows or hides the control.

The following methods for the Standard control are deprecated: addOnKeyPress, fireOnKeyPress, and removeOnKeyPress.

IFRAME control type

These methods are available for an IFRAME control.

Method Description
getContentWindow Returns the content window of the IFRAME or web resource.
getControlType Returns the type of the control.
getDisabled Returns whether the control is disabled.
getInitialUrl Returns the default URL configured for the IFRAME.
getLabel Returns the control's label.
getName Returns the control's name.
getObject Returns the form object that represents the IFRAME or web resource.
getParent Returns the section that contains the control.
getSrc Returns the URL currently displayed in the IFRAME or web resource.
getVisible Returns whether the control is visible.
setDisabled Enables or disables the control.
setFocus Moves focus to the control.
setLabel Changes the control's label.
setSrc Sets the URL to display in the IFRAME or web resource.
setVisible Shows or hides the control.

Kbsearch (knowledge base search) control type

These methods are available for the knowledge base search control.

Method Description
addOnPostSearch Adds an event handler that runs after a search completes.
addOnResultOpened Adds an event handler that runs when a search result opens.
addOnSelection Adds an event handler that runs when a search result is selected.
getControlType Returns the type of the control.
getDisabled Returns whether the control is disabled.
getLabel Returns the control's label.
getName Returns the control's name.
getParent Returns the section that contains the control.
getSearchQuery Returns the text used as the search criteria.
getSelectedResults Returns the currently selected search result.
getTotalResultCount Returns the number of search results.
getVisible Returns whether the control is visible.
openSearchResult Opens a specified search result.
removeOnPostSearch Removes an event handler for search completion.
removeOnResultOpened Removes an event handler for opening a search result.
removeOnSelection Removes an event handler for selecting a search result.
setFocus Moves focus to the control.
setLabel Changes the control's label.
setSearchQuery Sets the text used as the search criteria.
setVisible Shows or hides the control.

Note

When you add the knowledge base search control to the social pane, the control name is searchwidgetcontrol_notescontrol. You can't change this name.

Lookup control type

These methods are available for a lookup control.

Method Description
addCustomFilter Adds a filter to the lookup results, combined with existing filters by using AND.
addCustomView Adds a view to the lookup dialog.
addNotification Displays an error or recommendation notification with optional actions.
addOnLookupTagClick Adds an event handler that runs when a lookup tag is clicked.
addPreSearch Adds an event handler that runs before a lookup search.
clearNotification Removes a notification from the control.
getAttribute Returns the column that the control is bound to.
getControlType Returns the type of the control.
getDefaultView Returns the ID of the default lookup view.
getDisabled Returns whether the control is disabled.
getEntityTypes Returns the table types allowed in the lookup.
getLabel Returns the control's label.
getName Returns the control's name.
getParent Returns the section that contains the control.
getVisible Returns whether the control is visible.
removeOnLookupTagClick Removes an event handler for lookup tag clicks.
removePreSearch Removes an event handler that runs before a lookup search.
setDefaultView Sets the default view in the lookup dialog.
setDisabled Enables or disables the control.
setEntityTypes Sets the table types allowed in the lookup.
setFocus Moves focus to the control.
setLabel Changes the control's label.
setNotification Displays an error message to indicate that data isn't valid.
setVisible Shows or hides the control.

Choices and choice control types

Choices and choice controls have the same set of methods available.

Method Description
addNotification Displays an error or recommendation notification with optional actions.
addOption Adds an option to the control.
clearNotification Removes a notification from the control.
clearOptions Removes all options from the control.
getAttribute Returns the column that the control is bound to.
getControlType Returns the type of the control.
getDisabled Returns whether the control is disabled.
getLabel Returns the control's label.
getName Returns the control's name.
getOptions Returns the available options, including the blank option and excluding removed options.
getParent Returns the section that contains the control.
getVisible Returns whether the control is visible.
removeOption Removes an option from the control.
setDisabled Enables or disables the control.
setFocus Moves focus to the control.
setLabel Changes the control's label.
setNotification Displays an error message to indicate that data isn't valid.
setVisible Shows or hides the control.

Quick form control type

See formContext.ui.quickForms for information about methods supported for this control type.

Subgrid control type

See Grids and subgrids for information about methods supported for this control type.

Timeline wall control type

The timeline control presents the posts, activities, and notes in a unified view. These methods are available for this control type.

Method Description
getControlType Returns the type of the control.
getDisabled Returns whether the control is disabled.
getLabel Returns the control's label.
getName Returns the control's name.
getParent Returns the section that contains the control.
getVisible Returns whether the control is visible.
refresh Refreshes the data displayed in the timeline.
setDisabled Enables or disables the control.
setFocus Moves focus to the control.
setLabel Changes the control's label.
setVisible Shows or hides the control.

Timer control type

These methods are available for the timer control.

Method Description
getControlType Returns the type of the control.
getDisabled Returns whether the control is disabled.
getLabel Returns the control's label.
getName Returns the control's name.
getParent Returns the section that contains the control.
getState Returns the current state of the timer.
getVisible Returns whether the control is visible.
refresh Refreshes the data displayed in the timer.
setDisabled Enables or disables the control.
setFocus Moves focus to the control.
setLabel Changes the control's label.
setVisible Shows or hides the control.

Web resource control type

A web resource control has the same set of methods available as the iframe control. See iframe control type.

Form component control type

A form component control type has the same set of methods available as the formContext on a main form. See Form component behavior > Client API.

Columns