編輯

共用方式為


formContext.getControl (Client API reference)

Gets a control on the form.

Note

getControl only works on controls in the form body and header. It's not supported for controls elsewhere on the page, even if they refer to the same column.

Syntax

formContext.getControl(arg);

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

Parameter

arg: Optional. You can access a control on a form by passing an argument as either the name or the index value of the control on a form. For example: formContext.getControl("firstname") or formContext.getControl(0). If the arg name is spelled wrong and isn't on the form, it returns null value.

When the arg value isn't provided, it returns an array of all the controls on the form.

Return Value

Type: Object collection, Object or null.

Description: Object collection if you use the method without any parameters. Object or null if you use the method with a parameter. If you use the name as a parameter and there are multiple controls for the same column, then only the first control is returned.

Tip

If you want to modify the all the controls bound to a column on a form, use the controls collection inside the column type. For example, to add notification to each control bound to the name column, you can do the following:

 const notification = {
 messages: ['Sample Notification on Name Controls'],
 notificationLevel: 'RECOMMENDATION',
 uniqueId: 'my_unique_id'};
formContext.getAttribute("name").controls.forEach(control => control.addNotification(notification));

formContext